diff --git a/addons/project_purchase/models/project_project.py b/addons/project_purchase/models/project_project.py index 2a880f7d3f5..0eb3004b80c 100644 --- a/addons/project_purchase/models/project_project.py +++ b/addons/project_purchase/models/project_project.py @@ -22,10 +22,10 @@ class Project(models.Model): query.add_where('purchase_order_line.analytic_distribution ?| %s', [[str(account_id) for account_id in self.analytic_account_id.ids]]) query_string, query_param = query.select( - 'jsonb_object_keys(analytic_distribution) as account_id', + 'jsonb_object_keys(purchase_order_line.analytic_distribution) as account_id', 'COUNT(DISTINCT(order_id)) as purchase_order_count', ) - query_string = f"{query_string} GROUP BY jsonb_object_keys(analytic_distribution)" + query_string = f"{query_string} GROUP BY jsonb_object_keys(purchase_order_line.analytic_distribution)" self._cr.execute(query_string, query_param) data = {int(record.get('account_id')): record.get('purchase_order_count') for record in self._cr.dictfetchall()}