[FIX] account: Error when installing module demo data

Before this commit, when trying to install the l10n_sa or l10n_ae localization,
we get an error in the chart template resulting in no demo data installed. In
fact, when doing a Command.update to link the account to the journal in the
files template_sa and template_ae. The "values" dict was always filled no matter
 the Command, this mistake had repercussion on the "deref" method.

 In the deref method we do a loop on values items, but in the case we are facing
 the last_part variable was filled with an integer.
 When doing the recursion in case command is a "create" or an "update", the new
 values is the last_part, so the loop on values items raised an error since we
 cannot do a .items() on an integer.

closes odoo/odoo#116643

Related: odoo/upgrade#4687
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
Maximilien (malb)
2023-07-10 15:32:08 +02:00
parent a5801a12b5
commit dab9b3d349
+3 -2
View File
@@ -264,8 +264,9 @@ class AccountChartTemplate(models.AbstractModel):
rec = self.ref(xmlid, raise_if_not_found=False)
if rec:
for fname in x2manyfields:
for i, (line, vals) in enumerate(zip(rec[fname], values[fname])):
values[fname][i] = Command.update(line.id, vals[2])
for i, (line, (command, _id, vals)) in enumerate(zip(rec[fname], values[fname])):
if command == Command.CREATE:
values[fname][i] = Command.update(line.id, vals)
if model_name == 'account.fiscal.position':
# Only add tax mappings containing new taxes