From d66eb0ca82e0bbfe25b89f9ab0bebf5b1f665338 Mon Sep 17 00:00:00 2001 From: "Dylan Kiss (dyki)" Date: Fri, 28 Oct 2022 10:24:12 +0000 Subject: [PATCH] [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) --- addons/account/models/account_report.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_report.py b/addons/account/models/account_report.py index f6a4a1ce988..b1a431daef4 100644 --- a/addons/account/models/account_report.py +++ b/addons/account/models/account_report.py @@ -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