Skip to content

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

Open
tafaRU wants to merge 1 commit into
SimoRubi:12.0-fix-sale_triple_discount-round_discountfrom
tafaRU:12.0-fix-sale_triple_discount-round_discount_digits
Open

[FIX] sale_triple_discount: restore original discount field's precision by using change_digit function#1
tafaRU wants to merge 1 commit into
SimoRubi:12.0-fix-sale_triple_discount-round_discountfrom
tafaRU:12.0-fix-sale_triple_discount-round_discount_digits

Conversation

@tafaRU
Copy link
Copy Markdown

@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
# 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@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