[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
This commit is contained in:
Cedric Snauwaert 2014-01-29 11:04:10 +01:00
parent dfd96e9d7c
commit e41b26f4e0
1 changed files with 11 additions and 0 deletions

View File

@ -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):