[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 <oco-odoo@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user