[FIX] stock: clean lot when put in pack

- 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) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2020-06-19 13:49:11 +00:00
parent bdcad21ccc
commit dd7d8cd43a
+6 -1
View File
@@ -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({