From 153c91352593b45555adbec222b70dd18c217ae6 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Thu, 15 Dec 2011 18:56:03 +0530 Subject: [PATCH 1/3] [FIX]delivery: make a name_search method on prfix lp bug: https://launchpad.net/bugs/904495 fixed bzr revid: mma@tinyerp.com-20111215132603-s1sl8s214kc53gka --- addons/stock/stock.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 461c863aaed..adb04b9136d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1360,6 +1360,11 @@ class stock_production_lot(osv.osv): name = '%s [%s]' % (name, record['ref']) res.append((record['id'], name)) return res + + def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): + ids = self.search(cr, user, [('prefix',operator,name)]+ args, limit=limit, context=context) + result = self.name_get(cr, user, ids, context=context) + return result _name = 'stock.production.lot' _description = 'Production lot' From 82882c4b4d1eabb5e0b642a29f5cebe01f28541b Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Fri, 16 Dec 2011 11:40:09 +0530 Subject: [PATCH 2/3] [FIX]stock: improve a name_serch method for name and prefix bzr revid: mma@tinyerp.com-20111216061009-8g3oo2u190empr5u --- addons/stock/stock.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index adb04b9136d..cca636167ee 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1361,10 +1361,16 @@ class stock_production_lot(osv.osv): res.append((record['id'], name)) return res - def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): - ids = self.search(cr, user, [('prefix',operator,name)]+ args, limit=limit, context=context) - result = self.name_get(cr, user, ids, context=context) - return result + 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', operator, name)] + args, limit=limit, context=context or {}) + if not ids: + ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context or {}) + else: + ids = self.search(cr, uid, args, limit=limit, context=context or {}) + return self.name_get(cr, uid, ids, context or {}) _name = 'stock.production.lot' _description = 'Production lot' From c8a392ebcc61122a8b768ee6c91a2dc203c32b4e Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 21 Dec 2011 18:13:41 +0530 Subject: [PATCH 3/3] [IMP]stock:remove a {} bzr revid: mma@tinyerp.com-20111221124341-2syj4zsayed234eo --- addons/stock/stock.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index cca636167ee..a812db66c78 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1365,12 +1365,12 @@ class stock_production_lot(osv.osv): args = args or [] ids = [] if name: - ids = self.search(cr, uid, [('prefix', operator, name)] + args, limit=limit, context=context or {}) + ids = self.search(cr, uid, [('prefix', operator, name)] + args, limit=limit, context=context) if not ids: - ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context or {}) + ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context) else: - ids = self.search(cr, uid, args, limit=limit, context=context or {}) - return self.name_get(cr, uid, ids, context or {}) + 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'