From e6092c1aa74a02e6bef0c09f083a2d958b45e056 Mon Sep 17 00:00:00 2001 From: "Julien CHEVREAU (JCU)" Date: Tue, 17 Nov 2020 09:23:30 +0000 Subject: [PATCH] [IMP] analytic_account: added support for code field with "doesn't contain" filter From now on, it is possible to use the analytic account's code field in the "doesn't contain" filter. Until now, only the name of the analytic account was processed when using this filter. When using the "Contains" filter, both the name and the code of the analytic account were taken into account, which was inconsistent with how the "Doesn't contain" filter worked. Ticket #2368695 closes odoo/odoo#61830 Signed-off-by: oco-odoo --- addons/analytic/models/analytic_account.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/analytic/models/analytic_account.py b/addons/analytic/models/analytic_account.py index c95ccd59994..01cb17fd9ea 100644 --- a/addons/analytic/models/analytic_account.py +++ b/addons/analytic/models/analytic_account.py @@ -155,7 +155,7 @@ class AccountAnalyticAccount(models.Model): @api.model def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): - if operator not in ('ilike', 'like', '=', '=like', '=ilike'): + if operator not in ('ilike', 'like', '=', '=like', '=ilike', 'not ilike'): return super(AccountAnalyticAccount, self)._name_search(name, args, operator, limit, name_get_uid=name_get_uid) args = args or [] if operator == 'ilike' and not (name or '').strip(): @@ -164,7 +164,8 @@ class AccountAnalyticAccount(models.Model): # `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)] + domain_operator = '&' if operator == 'not ilike' else '|' + domain = [domain_operator, domain_operator, ('code', operator, name), ('name', operator, name), ('partner_id', 'in', partner_ids)] return self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)