From 17039d8f4f17218fedafeae4a7f89dedc92035ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nshimiyimana=20S=C3=A9na?= Date: Mon, 4 Sep 2023 15:13:40 +0200 Subject: [PATCH] [FIX] account: include 'quantity' in '_compute_all_tax' dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary ------- This commit addresses an issue where fixed taxes were not calculated correctly when applied to a line with a price of 0. Steps to reproduce ------------------ 1. Create a fixed tax with an amount of 5. 2. Create an invoice with a line having zero price and apply the fixed tax. 3. Save the invoice. You should have a total of 5. 4. Change the quantity of the invoice line, to something like 2. 5. Save the invoice. We expect the total to be 10, but we get 5. opw-3212536 closes odoo/odoo#134762 X-original-commit: 2aafff6a36bd40719de9447a7ab9bf05274ff5d2 Signed-off-by: William André (wan) Signed-off-by: Séna Serge Nshimiyimana (sesn) --- addons/account/models/account_move_line.py | 2 +- addons/account/tests/test_invoice_taxes.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index e95879fb585..ea58820bc32 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -909,7 +909,7 @@ class AccountMoveLine(models.Model): else: line.tax_key = frozendict({'id': line.id}) - @api.depends('tax_ids', 'currency_id', 'partner_id', 'analytic_distribution', 'balance', 'partner_id', 'move_id.partner_id', 'price_unit') + @api.depends('tax_ids', 'currency_id', 'partner_id', 'analytic_distribution', 'balance', 'partner_id', 'move_id.partner_id', 'price_unit', 'quantity') def _compute_all_tax(self): for line in self: sign = line.move_id.direction_sign diff --git a/addons/account/tests/test_invoice_taxes.py b/addons/account/tests/test_invoice_taxes.py index d6b5cdd09bb..8fd81022461 100644 --- a/addons/account/tests/test_invoice_taxes.py +++ b/addons/account/tests/test_invoice_taxes.py @@ -715,3 +715,22 @@ class TestInvoiceTaxes(AccountTestInvoicingCommon): self.assertRecordValues(invoice.line_ids.filtered(lambda l: l.account_id.account_type == 'asset_receivable'), [{ 'balance': 686.54, }]) + + def test_fixed_tax_with_zero_price(self): + fixed_tax = self.env['account.tax'].create({ + 'name': 'Test 5 fixed', + 'amount_type': 'fixed', + 'amount': 5, + }) + invoice = self._create_invoice([ + (0, fixed_tax), + ]) + self.assertRecordValues(invoice.line_ids.filtered('tax_line_id'), [{ + 'credit': 5.0, + 'debit': 0, + }]) + invoice.invoice_line_ids.quantity = 2 + self.assertRecordValues(invoice.line_ids.filtered('tax_line_id'), [{ + 'credit': 10.0, + 'debit': 0, + }])