[FIX] mrp: change production quantity is wrong on finished moves

Usecase to reproduce:
- BoM -> 1 component for 1 final product
- Create a MO with a quanity of 5
- Update the quantity to 6

-> The move finished has an initial demand of 4
This commit is contained in:
Arnold Moyaux
2019-08-19 14:14:13 +00:00
parent 876c7522fc
commit 44507c039e
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -516,6 +516,7 @@ class TestMrpOrder(TestMrpCommon):
update_quantity_wizard.change_prod_qty()
self.assertEqual(mo.move_raw_ids.filtered(lambda m: m.product_id == p1).quantity_done, 20, 'Update the produce quantity should not impact already produced quantity.')
self.assertEqual(mo.move_finished_ids.product_uom_qty, 4)
mo.button_mark_done()
def test_product_produce_6(self):
+2 -2
View File
@@ -35,8 +35,8 @@ class ChangeProductionQty(models.TransientModel):
modification = {}
for move in production.move_finished_ids.filtered(lambda m: m.state not in ('done', 'cancel')):
qty = (qty - old_qty) * move.unit_factor
modification[move] = (move.product_uom_qty - qty, move.product_uom_qty)
move[0].write({'product_uom_qty': move.product_uom_qty - qty})
modification[move] = (move.product_uom_qty + qty, move.product_uom_qty)
move[0].write({'product_uom_qty': move.product_uom_qty + qty})
return modification
def change_prod_qty(self):