From 6e25d6e589e4aa79768c483bca5c5669aaf52376 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 29 Apr 2015 16:27:55 +0200 Subject: [PATCH] [FIX] stock: better recomputation of pack operations Revert c06a96 "[FIX] stock: force recomputing transfer information on picking" and unlink packoperations only when move lines are changed (fix opw 620636). c06a96 introduced a regression as it prevents to plan moves (e.g. assigning lots through the barcode interface) before the reception. --- addons/stock/stock.py | 6 ++++++ addons/stock/wizard/stock_transfer_details.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 9016344abb2..1606a7e4936 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -942,6 +942,12 @@ class stock_picking(osv.osv): return super(stock_picking, self).unlink(cr, uid, ids, context=context) def write(self, cr, uid, ids, vals, context=None): + if vals.get('move_lines') and not vals.get('pack_operation_ids'): + # pack operations are directly dependant of move lines, it needs to be recomputed + pack_operation_obj = self.pool['stock.pack.operation'] + existing_package_ids = pack_operation_obj.search(cr, uid, [('picking_id', 'in', ids)], context=context) + if existing_package_ids: + pack_operation_obj.unlink(cr, uid, existing_package_ids, context) res = super(stock_picking, self).write(cr, uid, ids, vals, context=context) #if we changed the move lines or the pack operations, we need to recompute the remaining quantities of both if 'move_lines' in vals or 'pack_operation_ids' in vals: diff --git a/addons/stock/wizard/stock_transfer_details.py b/addons/stock/wizard/stock_transfer_details.py index ed03413f5fa..17f302f6317 100644 --- a/addons/stock/wizard/stock_transfer_details.py +++ b/addons/stock/wizard/stock_transfer_details.py @@ -48,7 +48,8 @@ class stock_transfer_details(models.TransientModel): picking = self.pool.get('stock.picking').browse(cr, uid, picking_id, context=context) items = [] packs = [] - picking.do_prepare_partial() + if not picking.pack_operation_ids: + picking.do_prepare_partial() for op in picking.pack_operation_ids: item = { 'packop_id': op.id,