[IMP] models: name_search() should call _name_search()
authorRaphael Collet <rco@openerp.com>
Wed, 6 Aug 2014 09:40:03 +0000 (11:40 +0200)
committerRaphael Collet <rco@openerp.com>
Wed, 6 Aug 2014 13:21:58 +0000 (15:21 +0200)
This avoids code duplication between methods, and keeps backward compatibility
with existing code overriding _name_search().

openerp/models.py

index 5280117..8beb60d 100644 (file)
@@ -1729,12 +1729,7 @@ class BaseModel(object):
             :rtype: list
             :return: list of pairs ``(id, text_repr)`` for all matching records.
         """
-        args = list(args or [])
-        if not self._rec_name:
-            _logger.warning("Cannot execute name_search, no _rec_name defined on %s", self._name)
-        elif not (name == '' and operator == 'ilike'):
-            args += [(self._rec_name, operator, name)]
-        return self.search(args, limit=limit).name_get()
+        return self._name_search(name, args, operator, limit=limit)
 
     def _name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100, name_get_uid=None):
         # private implementation of name_search, allows passing a dedicated user