Skip to content

[16.0][IMP] sale_triple_discount: Compute amount with decimal precision of 16 #2649

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

Closed
wants to merge 1 commit into from

Conversation

hildickethan
Copy link
Member

@hildickethan hildickethan changed the title [IMP] sale_triple_discount: Compute amount with decimal precision of 16 [16.0][IMP] sale_triple_discount: Compute amount with decimal precision of 16 Aug 21, 2023
Copy link
Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

Could you add a test case for this ?

@hildickethan
Copy link
Member Author

Could you add a test case for this ?

Added the exact use case I had issues with, if you multiply 138*2*0.55*0.95*0.9 you get 129.789 which without these changes Odoo cuts off at 129.78 because the "final discount" gets cut off at 2 decimal precision and then in turn on the invoice it calculates 129.79 because it calculates with 16 digits, causing the mismatch

@@ -97,6 +97,9 @@ def triple_discount_preprocess(self):
this method is called multiple times."""

prev_values = dict()
digits = self._fields["discount"]._digits
self.env["sale.order.line"]._fields["discount"]._digits = (16, 16)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not fan of this. I think this could lead to unwanted side effects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its not very pretty but I think it hasn't caused any issues for us so far, its mainly copying the process in the account equivalent module https://github.com/OCA/account-invoicing/blob/d2e12c03b50011bb788cf482346710f0fefe0de3/account_invoice_triple_discount/models/account_move_line.py#L73-L74 so it calculates the same discount, otherwise it can lead to different rounding

@hildickethan hildickethan force-pushed the 16.0-triple_16digits branch 2 times, most recently from 78a1fbe to c178a00 Compare May 21, 2024 14:23
@sbiosca-s73 sbiosca-s73 force-pushed the 16.0-triple_16digits branch from c178a00 to a0a1daf Compare October 1, 2024 06:25
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 Apr 13, 2025
@github-actions github-actions bot closed this May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs review 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.

3 participants