From a3390b0f96de01113fb418d999483bf67b9db869 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 27 Jun 2014 15:33:07 +0200 Subject: [PATCH] [IMP] Try to solve BoM expansion + check for context for splitting/copying moves --- addons/mrp/stock.py | 3 ++- addons/purchase/stock.py | 2 +- addons/stock/stock.py | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 1ff7e7e7c8c..0d59e396ecc 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -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 diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 26d2ff1002f..689884a0db0 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -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, diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0b31983150c..fde840bf7e8 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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'):