diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 47806b952d6..2f8389069d6 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -568,7 +568,7 @@ class AccountTax(models.Model): sum_repartition_factor = sum(tax_repartition_lines.mapped('factor')) #compute the tax_amount - if not skip_checkpoint and price_include and total_included_checkpoints.get(i): + if not skip_checkpoint and price_include and total_included_checkpoints.get(i) and sum_repartition_factor != 0: # We know the total to reach for that tax, so we make a substraction to avoid any rounding issues tax_amount = total_included_checkpoints[i] - (base + cumulated_tax_included_amount) cumulated_tax_included_amount = 0 diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index cbe043ada69..e9b769c0ffe 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -1109,3 +1109,61 @@ class TestTax(TestTaxCommon): ], (tax_10_fix + tax_21).compute_all(1210), ) + + def test_price_included_repartition_sum_0(self): + """ Tests the case where a tax with a non-zero value has a sum + of tax repartition factors of zero and is included in price. It + shouldn't behave in the same way as a 0% tax. + """ + test_tax = self.env['account.tax'].create({ + 'name': "Definitely not a 0% tax", + 'amount_type': 'percent', + 'amount': 42, + 'price_include': True, + 'invoice_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + }), + + (0, 0, { + 'factor_percent': -100, + 'repartition_type': 'tax', + }), + ], + 'refund_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + }), + + (0, 0, { + 'factor_percent': -100, + 'repartition_type': 'tax', + }), + ], + }) + + compute_all_res = test_tax.compute_all(100) + self._check_compute_all_results( + 100, # 'total_included' + 100, # 'total_excluded' + [ + # base , amount + # --------------- + (100, 42), + (100, -42), + # --------------- + ], + compute_all_res + )