[FIX] mrp: perform location chaining for kit exploded moves

This rev. 7307227 ensured to not (re-)set the state 'confirmed' to exploded moves with a more advanced state (for instance, 'assigned')
Nevertheless, the location chaining is performed on the move confirmation, through the action_confirm method of the stock.move model. Besides, the resulting moves of the _action_explode method had the state 'confirmed' on creation, the 'confirmed' state wasn't set by the method 'action_confirm', meaning that the moves were confirmed without having the location chaining done. Allowing moves to go through the action_confirm method even if the state was 'confirmed' or further triggered the location chaining.

Preventing already confirmed moves to go through the action_confirm method prevented the location chaining, thus.

We now create the resulting moves with the 'draft' state, and then confirm them through the procurement workflow signal 'button_confirm'. Thus, the resulting moves are confirmed by going through the action_confirm method, writing the confirmed state and triggering the location chaining at the same time. We then write the 'assigned' state if necessary.

opw-617235
This commit is contained in:
Denis Ledoux 2014-11-19 13:24:32 +01:00
parent bb7a9dea8b
commit 529e920b2c
1 changed files with 4 additions and 4 deletions

View File

@ -56,9 +56,6 @@ class StockMove(osv.osv):
factor = move.product_qty
bom_point = bom_obj.browse(cr, uid, bis[0], context=context)
res = bom_obj._bom_explode(cr, uid, bom_point, factor, [])
state = 'confirmed'
if move.state == 'assigned':
state = 'assigned'
for line in res[0]:
valdef = {
'picking_id': move.picking_id.id,
@ -68,7 +65,7 @@ class StockMove(osv.osv):
'product_uos': line['product_uos'],
'product_uos_qty': line['product_uos_qty'],
'move_dest_id': move.id,
'state': state,
'state': 'draft', #will be confirmed below
'name': line['name'],
'move_history_ids': [(6,0,[move.id])],
'move_history_ids2': [(6,0,[])],
@ -100,6 +97,9 @@ class StockMove(osv.osv):
for m in procurement_obj.search(cr, uid, [('move_id','=',move.id)], context):
wf_service.trg_validate(uid, 'procurement.order', m, 'button_confirm', cr)
wf_service.trg_validate(uid, 'procurement.order', m, 'button_wait_done', cr)
if processed_ids and move.state == 'assigned':
# Set the state of resulting moves according to 'assigned' as the original move is assigned
move_obj.write(cr, uid, list(set(processed_ids) - set([move.id])), {'state': 'assigned'}, context=context)
return processed_ids
def action_consume(self, cr, uid, ids, product_qty, location_id=False, context=None):