From 5805c032a4c8d388df2909715aac5eef8f464944 Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Wed, 6 Mar 2019 12:15:35 +0000 Subject: [PATCH] [FIX] analytic: name_search return no results - Since the commit 5fcf891e07bf61518e6bf0be0dc4f27859d45778 an issue has been introduced in the `analytic.account.analytic` name_search method. In some cases searching through analytic accounts will return no results when it should. The issue is due to a bug in `expression.py` that doesn't correctly handle the fields in `auto_join`. The issue is described here https://github.com/odoo/odoo/issues/25175 and will be fixed by the ORM team. closes odoo/odoo#31628 Signed-off-by: Christophe Simonis --- addons/analytic/models/analytic_account.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py index bc88e94a19e..acd5dfbc160 100644 --- a/addons/analytic/models/analytic_account.py +++ b/addons/analytic/models/analytic_account.py @@ -160,7 +160,10 @@ class AccountAnalyticAccount(models.Model): if operator == 'ilike' and not (name or '').strip(): domain = [] else: - domain = ['|', '|', ('code', operator, name), ('name', operator, name), ('partner_id.name', operator, name)] + # `partner_id` is in auto_join and the searches using ORs with auto_join fields doesn't work + # we have to cut the search in two searches ... https://github.com/odoo/odoo/issues/25175 + partner_ids = self.env['res.partner']._search([('name', operator, name)], limit=limit, access_rights_uid=name_get_uid) + domain = ['|', '|', ('code', operator, name), ('name', operator, name), ('partner_id', 'in', partner_ids)] analytic_account_ids = self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid) return self.browse(analytic_account_ids).name_get()