[FIX] project_purchase: use model indicator in query
This commit adds alias table to be sure the `analytic_distribution` column will not be ambiguous because another table could have the same column name. closes #121611 closes #110291 closes odoo/odoo#131991 X-original-commit: 253479633b32383e141fe2ca2ca7395f22651485 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
committed by
Xavier Bol (xbo)
parent
abda470f53
commit
8a7f221c91
@@ -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()}
|
||||
|
||||
Reference in New Issue
Block a user