Skip to content

Commit

Permalink
[IMP] sale_triple_discount: Compute amount with decimal precision of 16
Browse files Browse the repository at this point in the history
  • Loading branch information
hildickethan committed Aug 21, 2023
1 parent 0b84ffc commit 6eaf365
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sale_triple_discount/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
prev_values["discount_digits"] = digits
for line in self:
prev_values[line] = dict(
discount=line.discount,
Expand All @@ -115,6 +118,8 @@ def triple_discount_preprocess(self):
@api.model
def triple_discount_postprocess(self, prev_values):
"""Restore the discounts of the lines in the dictionary prev_values."""
digits = prev_values.pop("discount_digits")
self.env["sale.order.line"]._fields["discount"]._digits = digits
for line, prev_vals_dict in list(prev_values.items()):
line.update(prev_vals_dict)

Expand Down

0 comments on commit 6eaf365

Please sign in to comment.