From dd7d8cd43ae17d634b9f0dc07f78c88d39eb1008 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Fri, 19 Jun 2020 06:43:46 +0000 Subject: [PATCH] [FIX] stock: clean lot when put in pack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create a product with traceability per LOT enabled and a barcode; - Enable the option “Delivery Packages” in the inventory settings; - Go to "Barcode" app; - Scan EAN, the product line will be selected; - Scan a LOT, a unit of quantity is incremented at each time the LOT is scanned; - Put in Pack; - Scan again the same EAN to register the next LOT, the product line will be selected with remaining quantities; - Scan a new LOT number. Before this commit, as the product line will remain with the old LOT number, when the new LOT number is scanned a new line is created. This line will miss the initial quantity and the quantities added to this new line will not decrement the original line quantity. Now, the old LOT number is clean when the Put in Pack function is called. opw-2270781 closes odoo/odoo#53337 X-original-commit: 01bf263acbe406d45a4b7a5358bdcdfb70c1d9ed Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/stock/models/stock_picking.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 1067787dbd5..87b1f62f4af 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -1247,7 +1247,12 @@ class Picking(models.Model): done_to_keep = ml.qty_done new_move_line = ml.copy( default={'product_uom_qty': 0, 'qty_done': ml.qty_done}) - ml.write({'product_uom_qty': quantity_left_todo, 'qty_done': 0.0}) + vals = {'product_uom_qty': quantity_left_todo, 'qty_done': 0.0} + if ml.lot_id: + vals['lot_id'] = False + if ml.lot_name: + vals['lot_name'] = False + ml.write(vals) new_move_line.write({'product_uom_qty': done_to_keep}) move_lines_to_pack |= new_move_line package_level = self.env['stock.package_level'].create({