# -*- encoding: utf-8 -*- ############################################################################## # # Base Usability module for Odoo # Copyright (C) 2015 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## from openerp import models, api class Partner(models.Model): _inherit = 'res.partner' @api.model def name_search(self, name, args=None, operator='ilike', limit=100): if args is None: args = [] if name: # only filter on name and ref not in email args += [ '|', ('display_name', 'ilike', name), ('ref', 'ilike', name)] res = super(Partner, self).name_search( name, args=args, operator=operator, limit=limit) return [(pid, val.replace('\n', ' ')) for pid, val in res]