[MERGE] forward port of branch 7.0 up to 529e920
[odoo/odoo.git] / addons / mrp / stock.py
index c76b54d..08a74b3 100644 (file)
@@ -54,9 +54,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,
@@ -66,7 +63,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,[])],
@@ -99,6 +96,9 @@ class StockMove(osv.osv):
                 procurement_ids = procurement_obj.search(cr, uid, [('move_id','=',move.id)], context)
                 procurement_obj.signal_button_confirm(cr, uid, procurement_ids)
                 procurement_obj.signal_button_wait_done(cr, uid, procurement_ids)
+        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):