Skip to content

[FIX] account_invoice_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-account_invoice_triple_discount-subtotal_computationfrom
tafaRU:12.0-fix-account_invoice_triple_discount-subtotal_computation_digits
Open

[FIX] account_invoice_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-account_invoice_triple_discount-subtotal_computationfrom
tafaRU:12.0-fix-account_invoice_triple_discount-subtotal_computation_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.

# 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.

I think you can avoid this variable discount_original_digits... just assign dp.get_precision("Discount")(self.env.cr) in

discount_field._digits = discount_original_digits

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-account_invoice_triple_discount-subtotal_computation_digits branch from 475829f to 8aa2657 Compare August 3, 2021 15:45
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.

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


# Restore discount field's precision
discount_field._digits = discount_original_digits
discount_field._digits = dp.get_precision("Discount")(self.env.cr)
Copy link
Copy Markdown
Owner

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?

@tafaRU
Copy link
Copy Markdown
Author

tafaRU commented Mar 2, 2022

@SimoRubi have you seen SimoRubi/sale-workflow#1 (comment) ?

@SimoRubi
Copy link
Copy Markdown
Owner

SimoRubi commented Mar 3, 2022

@SimoRubi have you seen SimoRubi/sale-workflow#1 (comment) ?

yes, but I don't think that changes the status of that PR

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.

3 participants