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,