Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] barcodes_generator_abstract: Avoid double iteration on base generation #619

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

dalonsofl
Copy link

Module

barcodes_generator_abstract

Describe the bug

The base is changed when it is generated by having the ‘Automatic generation’ marked in the barcode nomenclature.

To Reproduce

  1. Configure the Automatic generation in the barcode nomenclature
  2. Create / Edit a product barcode rule
  3. Press on "Generate base"

(image from runboat OCA)

image

image

image

image

Affected versions:

16.0

Additional context

The problem is that when going through this function inside the barcodes_generator_product it goes back through the generate_base() and a recalculation of the base incorrectly, as it already has one before. With this change it would be solved

@OCA-git-bot
Copy link
Contributor

Hi @legalsylvain,
some modules you are maintaining are being modified, check this out!

@dalonsofl dalonsofl force-pushed the 16.0-fix-barcodes_generator_abstract branch from b142dde to 43d3c16 Compare May 29, 2024 16:53
@dalonsofl dalonsofl force-pushed the 16.0-fix-barcodes_generator_abstract branch from 43d3c16 to 04daac1 Compare May 29, 2024 16:58
Comment on lines -85 to -89
self.user_fake.generate_base()
self.assertEqual(self.user_fake.barcode_base, 2)
self.user_fake.generate_barcode()
self.assertEqual(self.user_fake.barcode, "2000002000006")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove this test. It looks valid ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Because it will be the same base and barcode. With this change if the product already has a base, it will not generate a new one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code is called two times, It should be fixed. But this change is not desired.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't undestand really well, it make sense that it doesn't change because you can't change the base two times in UI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I did'nt understood the point. I'll investigate a little.
Thanks for your time.

Copy link

@aliciagaarzo aliciagaarzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants