[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 <las@odoo.com>
This commit is contained in:
oco-odoo
2022-10-10 09:48:11 +02:00
parent e6e55f51bc
commit ed0f053046
+2
View File
@@ -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<quote>['"])(?P<xmlid>.+?)(?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: