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

[FIX] sale_triple_discount: restore original discount field's precision by using change_digit function #1

Open
wants to merge 1 commit into
base: 12.0-fix-sale_triple_discount-round_discount
Choose a base branch
from

Conversation

tafaRU
Copy link

@tafaRU tafaRU commented Aug 2, 2021

Use change_digit function to restore original discount field's precision in order to avoid to have always (16, 10) as precision in case of any errors.

@tafaRU tafaRU changed the title Use change_digit function to restore original discount field's precision in order to avoid to have always (16, 10) as precision in case of any errors. [FIX] sale_triple_discount: restore original discount field's precision by using change_digit function Aug 2, 2021
@@ -113,7 +113,7 @@ def triple_discount_preprocess(self):
# more digits than allowed from field's precision,
# so let's increase it just for saving it correctly in cache
discount_field = self._fields['discount']
discount_original_digits = discount_field._digits
discount_original_digits = dp.get_precision("Discount")(self.env.cr)

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks!

…ion in order to avoid to have always (16, 10) as precision in case of any errors.
@tafaRU tafaRU force-pushed the 12.0-fix-sale_triple_discount-round_discount_digits branch from f5020b6 to 094fb5b Compare August 3, 2021 15:51
Copy link
Owner

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

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

@tafaRU
Copy link
Author

tafaRU commented Sep 1, 2021

I'm proposing this PR (paired with SimoRubi/account-invoicing#1) to fix a strange behaviour that happend to one of our customers which is using OCA#1618 + OCA/account-invoicing#876
Unfortunately I didn't discover the root cause but I was able to replicate it by following these steps:

  • set a visual breakpoint here
  • jump to next line by skipping the restore of precision
  • reload the page
  • create a new Sale Order

In this way the attribute _digits of the field discount will remain equal to (16, 10).

By using this PR (paired with SimoRubi/account-invoicing#1) seems the problem was solved.

@rousseldenis
Copy link

@tafaRU @SimoRubi Something that will be decided here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants