From e41b26f4e0c22c9224947d2b334668543563c257 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 29 Jan 2014 11:04:10 +0100 Subject: [PATCH] [FIX]putaway location should be taken into account when force_assign a move lp bug: https://launchpad.net/bugs/1273635 fixed bzr revid: csn@openerp.com-20140129100410-6r185w2jkm4oporu --- addons/stock/stock.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 899d253e70c..3bdd95c11f4 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1481,6 +1481,7 @@ class stock_move(osv.osv): moveputaway_obj = self.pool.get('stock.move.putaway') quant_obj = self.pool.get('stock.quant') if putaway.method == 'fixed' and putaway.location_spec_id: + qty = move.product_qty for row in quant_obj.read_group(cr, uid, [('reservation_id', '=', move.id)], ['qty', 'lot_id'], ['lot_id'], context=context): vals = { 'move_id': move.id, @@ -1489,6 +1490,14 @@ class stock_move(osv.osv): 'lot_id': row.get('lot_id') and row['lot_id'][0] or False, } moveputaway_obj.create(cr, SUPERUSER_ID, vals, context=context) + qty -= row['qty'] + if qty > 0: + vals = { + 'move_id': move.id, + 'location_id': putaway.location_spec_id.id, + 'quantity': qty, + } + moveputaway_obj.create(cr, SUPERUSER_ID, vals, context=context) def _putaway_check(self, cr, uid, ids, context=None): for move in self.browse(cr, uid, ids, context=context): @@ -1723,6 +1732,8 @@ class stock_move(osv.osv): """ Changes the state to assigned. @return: True """ + #check putaway method + self._putaway_check(cr, uid, ids, context=context) return self.write(cr, uid, ids, {'state': 'assigned'}) def cancel_assign(self, cr, uid, ids, context=None):