From 872896947edda39c7980dc36791e22be4eb44ad2 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 1 Oct 2015 16:31:52 +0200 Subject: [PATCH] [FIX] stock: allow moving a pack with a product with lots and main_domain and action_done should be rebuilt every time Main_domain for getting preferred_quants needs to be reset every time. (otherwise the method will change it every time and it will lead to inconsistent results) An entire pack can be moved also when the products inside require lot tracking. (check_tracking update) There is no check if the quants have lots when a pack is moved entirely. On the other hand, the "put in pack" checks that what is put in it has the necessary lots. (but if incoming is without lots and outgoing with, you can still do an entire pack out without lots) --- addons/stock/stock.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7025643de85..9d1d26cc0d1 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2316,7 +2316,7 @@ class stock_move(osv.osv): """ if move.picking_id and (move.picking_id.picking_type_id.use_existing_lots or move.picking_id.picking_type_id.use_create_lots) and \ move.product_id.tracking != 'none': - if not (move.restrict_lot_id or (ops and ops.pack_lot_ids)): + if not (move.restrict_lot_id or (ops and (ops.product_id and ops.pack_lot_ids)) or (ops and not ops.product_id)): raise UserError(_('You need to provide a Lot/Serial Number for product %s') % move.product_id.name) def check_recompute_pack_op(self, cr, uid, ids, context=None): @@ -2577,7 +2577,6 @@ class stock_move(osv.osv): for ops in operations: if ops.picking_id: pickings.add(ops.picking_id.id) - main_domain = [('qty', '>', 0)] entire_pack=False if ops.product_id: #If a product is given, the result is always put immediately in the result package (if it is False, they are without package) @@ -2608,16 +2607,15 @@ class stock_move(osv.osv): move_qty_ops[move] += record.qty #Process every move only once for every pack operation for move in move_qty_ops: + main_domain = [('qty', '>', 0)] self.check_tracking(cr, uid, move, ops, context=context) preferred_domain = [('reservation_id', '=', move.id)] fallback_domain = [('reservation_id', '=', False)] fallback_domain2 = ['&', ('reservation_id', '!=', move.id), ('reservation_id', '!=', False)] - dom = main_domain if not ops.pack_lot_ids: preferred_domain_list = [preferred_domain] + [fallback_domain] + [fallback_domain2] - quants = quant_obj.quants_get_preferred_domain(cr, uid, move_qty_ops[move], move, ops=ops, domain=dom, + quants = quant_obj.quants_get_preferred_domain(cr, uid, move_qty_ops[move], move, ops=ops, domain=main_domain, preferred_domain_list=preferred_domain_list, context=context) - quant_obj.quants_move(cr, uid, quants, move, ops.location_dest_id, location_from=ops.location_id, lot_id=False, owner_id=ops.owner_id.id, src_package_id=ops.package_id.id, dest_package_id=quant_dest_package_id, entire_pack=entire_pack, context=context)