[FIX] account: reports: allow constant factors when expanding an aggregation expression

Before this fix, the expansion helper did not support formulas in the form

LINE1.label / LINE2.label * 100

because "100" couldn't be splitted between line code and expression label.

This case is now supported, as it is required for reports needing to compute percentages using other lines' values, like the executive summary.

closes odoo/odoo#102470

X-original-commit: ea2347e7ce43f8129568e6d4a8734ea8ebfc3b96
Related: odoo/enterprise#32425
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
This commit is contained in:
oco-odoo
2022-10-07 12:41:17 +02:00
parent 7fb0b88403
commit 21c8685f78
+1 -1
View File
@@ -511,7 +511,7 @@ class AccountReportExpression(models.Model):
expression_terms = re.split('[-+/*]', re.sub(r'[\s()]', '', expression.formula))
for term in expression_terms:
if term: # term might be empty if the formula contains a negative term
if term and not re.match(r'^([0-9]*[.])?[0-9]*$', term): # term might be empty if the formula contains a negative term
line_code, total_name = term.split('.')
totals_by_code[line_code].add(total_name)