-
Notifications
You must be signed in to change notification settings - Fork 0
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] account_invoice_triple_discount: restore original discount field's precision by using change_digit function #1
base: 12.0-fix-account_invoice_triple_discount-subtotal_computation
Are you sure you want to change the base?
Conversation
@@ -84,7 +84,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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can avoid this variable discount_original_digits
... just assign dp.get_precision("Discount")(self.env.cr)
in
account-invoicing/account_invoice_triple_discount/models/line_triple_discount.py
Line 103 in 475829f
discount_field._digits = discount_original_digits |
There was a problem hiding this comment.
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.
475829f
to
8aa2657
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test case for the errors you mentioned in the PR description?
I don't see how previous code could fail more than the one you are proposing here
@@ -100,7 +99,7 @@ def triple_discount_preprocess(self): | |||
}) | |||
|
|||
# Restore discount field's precision | |||
discount_field._digits = discount_original_digits | |||
discount_field._digits = dp.get_precision("Discount")(self.env.cr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are hardcoding 'Discount'
precision for the field while previous code restored the original precision of the field.
How is this taking care of errors more than previous code?
@SimoRubi have you seen SimoRubi/sale-workflow#1 (comment) ? |
yes, but I don't think that changes the status of that PR |
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.