From 0f1b61c250d5b1f7b95d62f18c11309fd13141dd Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 22 Oct 2021 14:08:20 +0000 Subject: [PATCH] [FIX] mail: progress bar if from parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there was parameters in the from clause, there was a possible error when reading progress bar for activities. eg. grouping product.product by "Routes" raise an error because we have in FORM clause like: FROM … ON … AND "product_template__route_ids"."route_id" IN (SELECT … WHERE … OR ("stock_location_route"."company_id" in %s)) so when we add timezone to parameters, it should be after FROM clause parameters and before WHERE clause parameters. opw-2674179 closes odoo/odoo#78837 Signed-off-by: Nicolas Lempereur (nle) --- addons/mail/models/mail_activity.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 26e07e001b8ce..3d90b9a22931b 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -853,7 +853,9 @@ def _read_progress_bar(self, domain, group_by, progress_bar): where_clause=where_clause or '1=1', group_by=', '.join(groupby_terms), ) - self.env.cr.execute(select_query, [tz] * 3 + where_params) + num_from_params = from_clause.count('%s') + where_params[num_from_params:num_from_params] = [tz] * 3 # timezone after from parameters + self.env.cr.execute(select_query, where_params) fetched_data = self.env.cr.dictfetchall() self._read_group_resolve_many2one_fields(fetched_data, annotated_groupbys) data = [