diff --git a/addons/mrp/tests/test_byproduct.py b/addons/mrp/tests/test_byproduct.py index 5ff4354952c..3e79e2f88c9 100644 --- a/addons/mrp/tests/test_byproduct.py +++ b/addons/mrp/tests/test_byproduct.py @@ -473,3 +473,23 @@ class TestMrpByProduct(common.TransactionCase): mo.button_mark_done() self.assertEqual(len(mo.move_byproduct_ids.move_line_ids), 2) self.assertEqual(mo.move_byproduct_ids.product_id, mo.move_byproduct_ids.move_line_ids.product_id) + + def test_byproduct_qty_update(self): + """ + Test that byproduct quantity is updated to the quantity set on the Mo when the Mo is marked as done.ee + """ + self.bom_byproduct.byproduct_ids.product_qty = 0.0 + self.warehouse.manufacture_steps = 'pbm_sam' + mo = self.env["mrp.production"].create({ + 'product_id': self.product_a.id, + 'product_qty': 1.0, + 'bom_id': self.bom_byproduct.id, + }) + mo.action_confirm() + mo.move_byproduct_ids.quantity = 1.0 + mo.button_mark_done() + self.assertEqual(mo.state, 'done') + picking = mo.picking_ids.filtered(lambda p: p.location_dest_id == self.warehouse.lot_stock_id) + self.assertEqual(picking.state, 'assigned') + byproduct_move = picking.move_ids.filtered(lambda m: m.product_id == self.bom_byproduct.byproduct_ids.product_id) + self.assertEqual(byproduct_move.product_qty, 1.0) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index e44b8a35a7e..2ae144dacfe 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1776,8 +1776,6 @@ Please change the quantity done or the rounding precision of your unit of measur """ extra_move = self rounding = self.product_uom.rounding - if float_is_zero(self.product_uom_qty, precision_rounding=rounding): - return self # moves created after the picking is assigned do not have `product_uom_qty`, but we shouldn't create extra moves for them if float_compare(self.quantity, self.product_uom_qty, precision_rounding=rounding) > 0: # create the extra moves