[FIX] account: Delay of account.tax.repartition_line_ids must clear

When we delay the creation of `repartition_line_ids`, the `account.tax`
gets created with default `base` and `tax` repartition lines,
which we must get rid of when we update the tax with the delayed
repartition lines.

related PR: #148370
task-3607459

closes odoo/odoo#157918

Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Paolo Gatti (pgi)
2024-04-20 17:39:55 +00:00
parent 5f612922c1
commit 515ea2afb5
+9
View File
@@ -537,6 +537,15 @@ class AccountChartTemplate(models.AbstractModel):
to_be_removed = [] to_be_removed = []
for field_name, field_val in vals.items(): for field_name, field_val in vals.items():
if should_delay(created_models, yet_to_be_created_models, model, field_name, field_val): if should_delay(created_models, yet_to_be_created_models, model, field_name, field_val):
# Default repartition lines will be created when we create account.tax
# If we delay the creation of repartition_line_ids, then we must get rid of the defaults
if (
model == 'account.tax' and 'repartition_line_ids' in field_name
and not self.ref(xml_id, raise_if_not_found=False)
and all(isinstance(x, tuple | list) for x in field_val)
and all(int(x[0]) in Command for x in field_val)
):
field_val = [Command.clear()] + field_val
to_be_removed.append(field_name) to_be_removed.append(field_name)
to_delay[xml_id][field_name] = field_val to_delay[xml_id][field_name] = field_val
for field_name in to_be_removed: for field_name in to_be_removed: