[MERGE] stock: putaway applied also when availability is forced

lp bug: https://launchpad.net/bugs/1273635 fixed

bzr revid: qdp-launchpad@openerp.com-20140130091343-8d15mmqd9jq9yn2e
This commit is contained in:
Quentin (OpenERP) 2014-01-30 10:13:43 +01:00
commit 2dd1e8094c
1 changed files with 13 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,16 @@ 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 the quants assigned aren't fully explaining where the products have to be moved
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 +1734,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):