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

Closed

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 2 times, most recently 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
Contributor

Choose a reason for hiding this comment

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

I just investigated a little. the problem exists.

I permit me to fix it with #651.

@dalonsofl : could you review it ?

thanks !

Copy link
Author

Choose a reason for hiding this comment

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

Hi @legalsylvain !

I checked the PR and it looks great!

I change my test like yours and it seems to work great too.

I get the same value with your PR as mine, so both of them are correct.

What do you think with the new changes?

Thanks!!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @dalonsofl. Thanks for reviewing the other PR.
Well, I prefer to have explicit text that explain what does the generate_base() function, and to avoid to double check if barcode_base is defined.
I so merged the other PR.

thanks for raising the issue.

Copy link
Author

Choose a reason for hiding this comment

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

I agree, the result is the same, so if you think it's better to have comments on generate_base() , I'm fine with that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I merged the other PR, you can close this one.

thanks for the investigation.

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
Copy link

@amarcosg amarcosg left a comment

Choose a reason for hiding this comment

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

Code review LGTM!

@dalonsofl dalonsofl force-pushed the 16.0-fix-barcodes_generator_abstract branch from 9ac97b1 to cf04f74 Compare October 11, 2024 07:15
@dalonsofl dalonsofl closed this Oct 11, 2024
@dalonsofl dalonsofl reopened this Oct 11, 2024
@dalonsofl dalonsofl closed this Oct 11, 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.

6 participants