[IMP] Try to solve BoM expansion + check for context for splitting/copying moves
authorJosse Colpaert <jco@odoo.com>
Fri, 27 Jun 2014 13:33:07 +0000 (15:33 +0200)
committerJosse Colpaert <jco@odoo.com>
Fri, 27 Jun 2014 13:33:07 +0000 (15:33 +0200)
addons/mrp/stock.py
addons/purchase/stock.py
addons/stock/stock.py

index 1ff7e7e..0d59e39 100644 (file)
@@ -91,8 +91,9 @@ class StockMove(osv.osv):
                     'product_uos_qty': line['product_uos_qty'],
                     'state': state,
                     'name': line['name'],
+                    'procurement_id': move.procurement_id.id,
                 }
-                mid = move_obj.copy(cr, uid, move.id, default=valdef)
+                mid = move_obj.copy(cr, uid, move.id, default=valdef, context={'split': True})
                 to_explode_again_ids.append(mid)
 
             #delete the move with original product which is not relevant anymore
index 26d2ff1..689884a 100644 (file)
@@ -48,7 +48,7 @@ class stock_move(osv.osv):
     def copy(self, cr, uid, id, default=None, context=None):
         if not default:
             default = {}
-        if not default.get('split_from'):
+        if not default.get('split_from') and not context.get('split'):
             #we don't want to propagate the link to the purchase order line except in case of move split
             default.update({
                 'purchase_line_id': False,
index 0b31983..fde840b 100644 (file)
@@ -1752,13 +1752,17 @@ class stock_move(osv.osv):
         if default is None:
             default = {}
         default = default.copy()
-        default['move_orig_ids'] = []
         default['quant_ids'] = []
-        default['move_dest_id'] = False
         default['reserved_quant_ids'] = []
         default['returned_move_ids'] = []
         default['linked_move_operation_ids'] = []
         default['partially_available'] = False
+        if not default.get('move_orig_ids'):
+            default['move_orig_ids'] = []
+        if not default.get('move_dest_id'): 
+            default['move_dest_id'] = False
+        if not default.get('procurement_id'):
+            default['procurement_id'] = False
         if not default.get('origin_returned_move_id'):
             default['origin_returned_move_id'] = False
         default['state'] = 'draft'
@@ -2403,6 +2407,7 @@ class stock_move(osv.osv):
             'restrict_lot_id': restrict_lot_id,
             'restrict_partner_id': restrict_partner_id,
             'split_from': move.id,
+            'procurement_id': move.procurement_id.id,
             'move_dest_id': move.move_dest_id.id,
         }
         if context.get('source_location_id'):