[FIX] account: tax repart lines should have at least one tax line

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 <las@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2022-03-10 09:00:02 +00:00
parent a53344c34d
commit 0e37791e8b
2 changed files with 12 additions and 0 deletions
+8
View File
@@ -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
+4
View File
@@ -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]