[FIX] account: copy report aggregation lines correctly

Previously, when copying a report with top-level aggregation lines that reference other top-level lines, the codes in the aggregation formula where not correctly replaced.

This commit solves the issue, so reports can be correctly copied.

closes odoo/odoo#104632

X-original-commit: 94a524a1be42e2128b291a2357a637ddef4cce6b
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
This commit is contained in:
Dylan Kiss (dyki)
2022-10-31 17:00:43 +01:00
parent 8aac90bcbb
commit d66eb0ca82
+3 -2
View File
@@ -175,8 +175,9 @@ class AccountReport(models.Model):
default = {}
default['name'] = self._get_copied_name()
copied_report = super().copy(default=default)
code_mapping = {}
for line in self.line_ids.filtered(lambda x: not x.parent_id):
line._copy_hierarchy(copied_report)
line._copy_hierarchy(copied_report, code_mapping=code_mapping)
for column in self.column_ids:
column.copy({'report_id': copied_report.id})
return copied_report
@@ -296,7 +297,7 @@ class AccountReportLine(models.Model):
})
# Keep track of old_code -> new_code in a mutable dict
if not code_mapping:
if code_mapping is None:
code_mapping = {}
if self.code:
code_mapping[self.code] = copied_line.code