From 0e37791e8b643b1c21f2a98f7b91e48ca818bdba Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Thu, 3 Mar 2022 14:57:18 +0000 Subject: [PATCH] [FIX] account: tax repart lines should have at least one tax line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check to ensure that the repartition lines have at least one tax line. Reason: the compute_all fonction skips the taxes with no tax lines because it only loops over the tax repartition lines to fill taxes_vals closes odoo/odoo#85943 X-original-commit: 783d604fd66f813b66b0bac769f22c1dc0ed761f Signed-off-by: Laurent Smet Signed-off-by: William André (wan) Signed-off-by: Julien Van Roy --- addons/account/i18n/account.pot | 8 ++++++++ addons/account/models/account_tax.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index dded69d6da8..ff0c26d20cf 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -7032,6 +7032,14 @@ msgid "" "for the base." msgstr "" +#. module: account +#: code:addons/account/models/account_tax.py:0 +#, python-format +msgid "" +"Invoice and credit note repartition should have at least one tax repartition" +" line." +msgstr "" + #. module: account #: code:addons/account/models/account_tax.py:0 #, python-format diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 5b93b0cf889..62788dc1142 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -189,6 +189,10 @@ class AccountTax(models.Model): if len(invoice_repartition_line_ids) != len(refund_repartition_line_ids): raise ValidationError(_("Invoice and credit note distribution should have the same number of lines.")) + if not invoice_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax') or \ + not refund_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax'): + raise ValidationError(_("Invoice and credit note repartition should have at least one tax repartition line.")) + index = 0 while index < len(invoice_repartition_line_ids): inv_rep_ln = invoice_repartition_line_ids[index]