[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:Yannick Tivisse (yti) <yti@odoo.com>
Loading
Please register or sign in to comment