Skip to content
Snippets Groups Projects
Commit b3c539b0 authored by Manuel Vázquez Acosta's avatar Manuel Vázquez Acosta
Browse files

[FIX] base: Correct optimization of name_search


Commit 5fcf891e introduced optimizations for
name_search in several models.  However, that produces some counter-intuitive
searches.

In a DB with project and custom data:

    >>> Project = self.env['project.task']
    >>> Project.search([('user_id', 'ilike', 'demo')]).mapped('user_id.name')
    ['Marc Demo']

    >>> Project.search([('user_id', 'not ilike', 'demo')]).mapped('user_id.name')
    ['Marc Demo']

The projects returned with 'not ilike' are a super-set of those returned with
'ilike':

    >>> Project.search([('user_id', 'ilike', 'demo')])
    project.task(22, 21, 20, 16, 14, 13)

    >>> Project.search([('user_id', 'not ilike', 'demo')])
    project.task(22, 21, 29, 28, 27, 26, 25, 20, 16, 14, 13, 31, 30)

This commit fix this behaviour by choosing '!=' instead of '=' whenever the
operator is a negation operator.

The 'res.users' is more exposed than the other models touched by
5fcf891e, because user may search for 'Created
by' in the web client.

closes odoo/odoo#32561

Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent ca34dd39
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment