# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.tests.common import TransactionCase class TestPartner(TransactionCase): def test_name_search(self): """ Check name_search on partner, especially with domain based on auto_join user_ids field. Check specific SQL of name_search correctly handle joined tables. """ test_partner = self.env['res.partner'].create({'name': 'Vlad the Impaler'}) test_user = self.env['res.users'].create({'name': 'Vlad the Impaler', 'login': 'vlad', 'email': 'vlad.the.impaler@example.com'}) ns_res = self.env['res.partner'].name_search('Vlad', operator='ilike') self.assertEqual(set(i[0] for i in ns_res), set((test_partner | test_user.partner_id).ids)) ns_res = self.env['res.partner'].name_search('Vlad', args=[('user_ids.email', 'ilike', 'vlad')]) self.assertEqual(set(i[0] for i in ns_res), set(test_user.partner_id.ids))