You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1016 B

  1. # Copyright 2018 - TODAY Serpent Consulting Services Pvt. Ltd.
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, models
  4. class ResPartner(models.Model):
  5. _inherit = 'res.partner'
  6. @api.model
  7. def name_search(self, name, args=None, operator='ilike', limit=100):
  8. if not args:
  9. args = []
  10. if name:
  11. domain = ['|', '|', ('phone', operator, name),
  12. ('mobile', operator, name), ('email', operator, name)
  13. ]
  14. partners = self.search(domain + args, limit=limit,)
  15. res = partners.name_get()
  16. if limit:
  17. limit_rest = limit - len(partners)
  18. else:
  19. limit_rest = limit
  20. if limit_rest or not limit:
  21. args += [('id', 'not in', partners.ids)]
  22. res += super(ResPartner, self).name_search(
  23. name, args=args, operator=operator, limit=limit_rest)
  24. return res