From c9d436f089a553edb142029fefd7f830ec7678ed Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Wed, 11 May 2011 12:27:46 +0530 Subject: [PATCH 1/2] [FIX]stock:put constrain for restric view type location as destination in picking lp bug: https://launchpad.net/bugs/780354 fixed bzr revid: ron@tinyerp.com-20110511065746-ioojaku0d2os8gpz --- addons/stock/stock.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2d516f1a8a5..0985a74f92a 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -658,6 +658,19 @@ class stock_picking(osv.osv): 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'), 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c) } + + def _destination_location(self, cr, uid, ids, context=None): + if context is None: + context = {} + for record in self.browse(cr, uid, ids, context=context)[0].move_lines: + if record.location_dest_id.usage == 'view': + return False + return True + + _constraints = [ + (_destination_location, 'You cannot put view type location as Destination location.', ['location_dest_id']) + ] + def action_process(self, cr, uid, ids, context=None): if context is None: context = {} partial_id = self.pool.get("stock.partial.picking").create( From 33d7891b37474a25f3240e4f68912dcc1853b6c6 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 2 Jun 2011 10:57:54 +0530 Subject: [PATCH 2/2] [IMP]stock:Also put constrain for restric view type location as source location bzr revid: ron@tinyerp.com-20110602052754-8kdflqhpepg9v4tu --- addons/stock/stock.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0985a74f92a..85b580b8a4f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -659,16 +659,16 @@ class stock_picking(osv.osv): 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.picking', context=c) } - def _destination_location(self, cr, uid, ids, context=None): + def _check_location(self, cr, uid, ids, context=None): if context is None: context = {} for record in self.browse(cr, uid, ids, context=context)[0].move_lines: - if record.location_dest_id.usage == 'view': + if record.location_dest_id.usage == 'view' or record.location_id.usage == 'view': return False return True _constraints = [ - (_destination_location, 'You cannot put view type location as Destination location.', ['location_dest_id']) + (_check_location, 'You cannot put view type location as Source or Destination location.', ['location_id','location_dest_id']) ] def action_process(self, cr, uid, ids, context=None):