diff --git a/base_usability/partner.py b/base_usability/partner.py index 4a77e62..829c53e 100644 --- a/base_usability/partner.py +++ b/base_usability/partner.py @@ -62,18 +62,6 @@ class Partner(models.Model): name_title = ' '.join([title, name_title]) self.name_title = name_title - @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] - class ResPartnerCategory(models.Model): _inherit = 'res.partner.category' diff --git a/partner_search/__init__.py b/partner_search/__init__.py index e69de29..4da81fa 100644 --- a/partner_search/__init__.py +++ b/partner_search/__init__.py @@ -0,0 +1 @@ +from . import partner diff --git a/partner_search/partner.py b/partner_search/partner.py new file mode 100644 index 0000000..61cf364 --- /dev/null +++ b/partner_search/partner.py @@ -0,0 +1,39 @@ +# -*- 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]