diff options
| author | Olivier Colson <oco@odoo.com> | 2019-08-02 12:38:02 +0000 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2019-08-02 13:50:35 +0000 |
| commit | 5bacf72319c1e20b968bf4015ea395fffa2c536f (patch) | |
| tree | 9a66b8f9253f9efc6d78e9c67203c00c6e2e4253 | |
| parent | fd0813d50605567b57e825befb626aff783a4826 (diff) | |
[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 <smetl@users.noreply.github.com>
| -rw-r--r-- | addons/account/models/account.py | 6 |
1 files 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, |
