diff --git a/addons/stock/stock.py b/addons/stock/stock.py index e3d3a3be1cb..a1a0cbc3fca 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1360,6 +1360,17 @@ class stock_production_lot(osv.osv): name = '%s [%s]' % (name, record['ref']) res.append((record['id'], name)) return res + + def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): + args = args or [] + ids = [] + if name: + ids = self.search(cr, uid, [('prefix', '=', name)] + args, limit=limit, context=context) + if not ids: + ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context) + else: + ids = self.search(cr, uid, args, limit=limit, context=context) + return self.name_get(cr, uid, ids, context) _name = 'stock.production.lot' _description = 'Production lot'