From 2a449454cb15a3b74fc354ef6ff5ccfda0d17f4d Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Tue, 4 Oct 2022 13:52:32 +0000 Subject: [PATCH] [FIX] account: display tax base on invoice report The condition that determines whether to display the tax base was wrong It should be displayed when either condition is met: - There are multiple tax base amounts - The only tax base amount is not the same as the untaxed amount Note that this last case may happen with cash discounts closes odoo/odoo#102247 X-original-commit: a8ff4b876c8ab48177795e6ace1bb1361744c8a7 Signed-off-by: Camille Spiritus (casp) Signed-off-by: Stanislas Gueniffey (stgu) --- addons/account/models/account_tax.py | 3 ++- addons/account/tests/test_invoice_tax_totals.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 336f76396b9..7dcbb3b84c6 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -1188,7 +1188,8 @@ class AccountTax(models.Model): amount_total = amount_untaxed + amount_tax - display_tax_base = len(global_tax_details['tax_details']) == 1 and tax_group_vals['base_amount'] != amount_untaxed + display_tax_base = (len(global_tax_details['tax_details']) == 1 and tax_group_vals_list[0]['base_amount'] != amount_untaxed) \ + or len(global_tax_details['tax_details']) > 1 return { 'amount_untaxed': currency.round(amount_untaxed) if currency else amount_untaxed, diff --git a/addons/account/tests/test_invoice_tax_totals.py b/addons/account/tests/test_invoice_tax_totals.py index 476944e0af5..297d79cb8de 100644 --- a/addons/account/tests/test_invoice_tax_totals.py +++ b/addons/account/tests/test_invoice_tax_totals.py @@ -111,7 +111,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 3600, 'amount_untaxed': 3000, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { 'Untaxed Amount': [ { @@ -226,7 +226,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 3620, 'amount_untaxed': 3000, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { 'Untaxed Amount': [ { @@ -313,7 +313,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 2750, 'amount_untaxed': 2000, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { 'Untaxed Amount': [ { @@ -400,7 +400,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 2846, 'amount_untaxed': 2300, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { 'Untaxed Amount': [ { @@ -486,7 +486,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 1867, 'amount_untaxed': 1500, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { 'Untaxed Amount': [ { @@ -584,7 +584,7 @@ class TestTaxTotals(AccountTestInvoicingCommon): self.assertTaxTotals(document, { 'amount_total': 1230.41, 'amount_untaxed': 1020.41, - 'display_tax_base': False, + 'display_tax_base': True, 'groups_by_subtotal': { "Reapply amount": [{ 'tax_group_name': self.tax_group_sub3.name,