From e751d03012e49009374352b33fa16ca1e3d3a57f Mon Sep 17 00:00:00 2001
From: "Claire Bretton (clbr)" <clbr@odoo.com>
Date: Fri, 17 Feb 2023 12:32:00 +0000
Subject: [PATCH] [FIX] account: relax repartition lines validation when tax
 has children

If a tax is an aggregation of its sub-taxes it makes sense to have no
repartition line. This PR relaxes the validation in that case.

Part-of: odoo/odoo#113001
---
 addons/account/models/account_tax.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py
index 9840b794dbaa..10d1c1dab7d6 100644
--- a/addons/account/models/account_tax.py
+++ b/addons/account/models/account_tax.py
@@ -132,6 +132,12 @@ class AccountTax(models.Model):
     @api.constrains('invoice_repartition_line_ids', 'refund_repartition_line_ids')
     def _validate_repartition_lines(self):
         for record in self:
+            # if the tax is an aggregation of its sub-taxes (group) it can have no repartition lines
+            if record.amount_type == 'group' and \
+                    not record.invoice_repartition_line_ids and \
+                    not record.refund_repartition_line_ids:
+                continue
+
             invoice_repartition_line_ids = record.invoice_repartition_line_ids.sorted()
             refund_repartition_line_ids = record.refund_repartition_line_ids.sorted()
             record._check_repartition_lines(invoice_repartition_line_ids)
-- 
GitLab