From fac13263edc5b88cc47f19e70f9f356422336a77 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 24 Nov 2010 16:57:43 +0530 Subject: [PATCH] [IMP]: stock: Improvement in split lot and pack wizard to write move in inventory if wizard is used for inventory bzr revid: rpa@tinyerp.com-20101124112743-yf96yzwehdlu4qq1 --- addons/stock/wizard/stock_move.py | 6 ++---- addons/stock/wizard/stock_splitinto.py | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/stock/wizard/stock_move.py b/addons/stock/wizard/stock_move.py index 187cd009a4d..c10a0e63ec3 100644 --- a/addons/stock/wizard/stock_move.py +++ b/addons/stock/wizard/stock_move.py @@ -252,6 +252,8 @@ class split_in_production_lot(osv.osv_memory): } if quantity_rest > 0: current_move = move_obj.copy(cr, uid, move.id, default_val, context=context) + if inventory_id and current_move: + inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, current_move)]}, context=context) new_move.append(current_move) if quantity_rest == 0: @@ -274,10 +276,6 @@ class split_in_production_lot(osv.osv_memory): update_val['state'] = move.state move_obj.write(cr, uid, [move.id], update_val) - if inventory_id and new_move: - for m_id in new_move: - inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context) - return new_move split_in_production_lot() diff --git a/addons/stock/wizard/stock_splitinto.py b/addons/stock/wizard/stock_splitinto.py index 26a978ef077..171d7dd1e14 100644 --- a/addons/stock/wizard/stock_splitinto.py +++ b/addons/stock/wizard/stock_splitinto.py @@ -44,7 +44,6 @@ class stock_split_into(osv.osv_memory): inventory_obj = self.pool.get('stock.inventory') quantity = self.browse(cr, uid, data[0], context).quantity or 0.0 for move in move_obj.browse(cr, uid, rec_id): - new_move = [] quantity_rest = move.product_qty - quantity #if move.tracking_id : # raise osv.except_osv(_('Error!'), _('The current move line is already assigned to a pack, please remove it first if you really want to change it ' \ @@ -62,7 +61,6 @@ class stock_split_into(osv.osv_memory): 'product_uos': move.product_uom.id, }) - if quantity_rest>0: quantity_rest = move.product_qty - quantity tracking_id = track_obj.create(cr, uid, {}, context=context) @@ -77,11 +75,9 @@ class stock_split_into(osv.osv_memory): 'product_uos': move.product_uom.id } current_move = move_obj.copy(cr, uid, move.id, default_val, context=context) - new_move.append(current_move) + if inventory_id and current_move: + inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, current_move)]}, context=context) - if inventory_id and new_move: - for m_id in new_move: - inventory_obj.write(cr, uid, inventory_id, {'move_ids': [(4, m_id)]}, context=context) return {} stock_split_into()