From 5bacf72319c1e20b968bf4015ea395fffa2c536f Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Fri, 2 Aug 2019 12:38:02 +0000 Subject: [PATCH] [FIX] account: avoid rounding issues when using a tax with multiple repartition lines - create an invoice with only one line with a price of 91.56 - assign a tax of 15% using two 50% repartition lines to this invoice line ==> The total tax amount computed was 13.74; it should be 13.73. closes odoo/odoo#35412 Signed-off-by: Laurent Smet --- addons/account/models/account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 474cefd24ea..ba524640c38 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -1426,12 +1426,12 @@ class AccountTax(models.Model): subsequent_tags = subsequent_taxes.get_tax_tags(is_refund, 'base') # Compute the tax lines - tax_repartition_lines = is_refund and tax.refund_repartition_line_ids or tax.invoice_repartition_line_ids + tax_repartition_lines = (is_refund and tax.refund_repartition_line_ids or tax.invoice_repartition_line_ids).filtered(lambda x: x.repartition_type == 'tax') repartition_lines_to_treat = len(tax_repartition_lines) total_amount = 0 - for repartition_line in tax_repartition_lines.filtered(lambda x: x.repartition_type == 'tax'): + for repartition_line in tax_repartition_lines: # In case some rounding error occurs, we compensate for it on the last line - line_amount = round(sign * tax_amount * repartition_line.factor if repartition_lines_to_treat != 1 else tax_amount - total_amount, prec) + line_amount = round(sign * tax_amount * repartition_line.factor if repartition_lines_to_treat != 1 else sign * (tax_amount - total_amount), prec) taxes_vals.append({ 'id': tax.id,