[FIX] account_reports: aggregation engine: properly expand aggregation expressions when using an if_other_expr_[above|below] subformula

The if_other_expr_[above|below] subformulas were introduced in stable by https://github.com/odoo/enterprise/commit/f39862263c7e2332468a69736589a35d66d87b16. They basically allow displaying the value of an aggregation expression if another line's amount is above/below a provided bound. When using an expression with such a subformula to compute a carryover value (hence giving the expression a _carryover_... label) on a tax report, the posting of the said tax report's closing entry looped forever. No report from Odoo falls into this use case at the moment, but the issue occured on a development branch (for l10n_ma).

This was due to the fact the tax closing expands only the aggregation expressions needed in the computation of the carryover to compute its value, hence not providing all the expressions of the report. Doing so, _get_aggregation_terms_details was called, and it neglected to include the expression used as comparison term by the subformula into the dependencies of the aggregation to expand. As a result, the comparison term could never be evaluated, and the loop went on forever, waiting for the comparison term to receive a value.

closes odoo/odoo#118104

X-original-commit: 76288d1fd654c9ff4c721cc1d96596b6adbf95d0
Related: odoo/enterprise#39535
Signed-off-by: John Laterre (jol) <jol@odoo.com>
This commit is contained in:
oco-odoo
2023-04-11 09:21:13 +02:00
parent 5cbb0738be
commit 4f93fd0800
+5
View File
@@ -603,6 +603,11 @@ class AccountReportExpression(models.Model):
line_code, total_name = term.split('.')
totals_by_code[line_code].add(total_name)
if expression.subformula:
if_other_expr_match = re.match(r'if_other_expr_(above|below)\((?P<line_code>.+)[.](?P<expr_label>.+),.+\)', expression.subformula)
if if_other_expr_match:
totals_by_code[if_other_expr_match['line_code']].add(if_other_expr_match['expr_label'])
return totals_by_code
def _get_matching_tags(self, sign=None):