Skip to content
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

[14.0] FIX account_invoice_triple_discount - _recompute_tax_lines involving only relevant lines: invoice_line_ids #1592

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions account_invoice_triple_discount/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ def _recompute_tax_lines(self, **kwargs):
restored after the original process is done
"""
old_values_by_line_id = {}
digits = self.line_ids._fields["price_unit"]._digits
self.line_ids._fields["price_unit"]._digits = (16, 16)
for line in self.line_ids:
digits = self.invoice_line_ids._fields["price_unit"]._digits
self.invoice_line_ids._fields["price_unit"]._digits = (16, 16)
for line in self.invoice_line_ids:
aggregated_discount = line._compute_aggregated_discount(line.discount)
old_values_by_line_id[line.id] = {
"price_unit": line.price_unit,
"discount": line.discount,
}
price_unit = line.price_unit * (1 - aggregated_discount / 100)
line.update({"price_unit": price_unit, "discount": 0})
self.line_ids._fields["price_unit"]._digits = digits
self.invoice_line_ids._fields["price_unit"]._digits = digits
res = super(AccountMove, self)._recompute_tax_lines(**kwargs)
for line in self.line_ids:
for line in self.invoice_line_ids:
if line.id not in old_values_by_line_id:
continue
line.update(old_values_by_line_id[line.id])
Expand Down