[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. X-original-commit: a82404db4370c9b8f3ae1c58f1702abc98de0881 Part-of: odoo/odoo#121580
This commit is contained in:
@@ -272,6 +272,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(lambda l: (l.sequence, l.id))
|
||||
refund_repartition_line_ids = record.refund_repartition_line_ids.sorted(lambda l: (l.sequence, l.id))
|
||||
record._check_repartition_lines(invoice_repartition_line_ids)
|
||||
|
||||
Reference in New Issue
Block a user