From ed0f053046ba8a2aaf641b4b6f0b5789c768686f Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Mon, 3 Oct 2022 09:08:11 +0000 Subject: [PATCH] [FIX] account_reports: 'domain' engine: resolve calls to ref() when loading formula shortcuts The full syntax should make use of eval="..." directly in XML. Doing this leads to the fact the formulas, when displayed in the UI, don't contain any call to ref(), but directly the ids obtained from these calls. Before this commit, the shortcut syntax used to declare the same expressions did not work in the same way and kept an explicit ref() in the formula to evaluate. We now do the same in both places. We don't want to support explicit ref() in formulas (a user modifying a formula will anyway not know the xmlid to call). The enterprise part of this PR takes care of that. closes odoo/odoo#102718 X-original-commit: ea291e4d1dea374455cd8a15bf84662278f4a750 Related: odoo/enterprise#32542 Signed-off-by: Laurent Smet --- addons/account/models/account_report.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_report.py b/addons/account/models/account_report.py index 969a52e76df..bd215348763 100644 --- a/addons/account/models/account_report.py +++ b/addons/account/models/account_report.py @@ -343,6 +343,8 @@ class AccountReportLine(models.Model): if engine == 'domain' and report_line.domain_formula: subformula, formula = DOMAIN_REGEX.match(report_line.domain_formula or '').groups() + # Resolve the calls to ref(), to mimic the fact those formulas are normally given with an eval="..." in XML + formula = re.sub(r'''\bref\((?P['"])(?P.+?)(?P=quote)\)''', lambda m: str(self.env.ref(m['xmlid']).id), formula) elif engine == 'account_codes' and report_line.account_codes_formula: subformula, formula = None, report_line.account_codes_formula elif engine == 'aggregation' and report_line.aggregation_formula: