[FIX] mrp: fix change MO qty to produce
Before this commit, if a user changes a MO move qty to 0 and then tries to change the MO qty to produce, an error occurs. The move with 0 qty is no longer cancelled or unlinked as this was not the intenteded behavior. Since the change production wizard no longer deletes cancelled moves a test was updated accordingly. closes odoo/odoo#108534 Taskid: 3082611 X-original-commit: 39abadb30dc8fab6b2a1ca24cb2916ab148fb5fa Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com> Signed-off-by: Ahmed Khalaf <ahkh@odoo.com>
This commit is contained in:
@@ -1061,7 +1061,6 @@ class MrpProduction(models.Model):
|
||||
def _update_raw_moves(self, factor):
|
||||
self.ensure_one()
|
||||
update_info = []
|
||||
move_to_unlink = self.env['stock.move']
|
||||
moves_to_assign = self.env['stock.move']
|
||||
procurements = []
|
||||
for move in self.move_raw_ids.filtered(lambda m: m.state not in ('done', 'cancel')):
|
||||
@@ -1080,14 +1079,7 @@ class MrpProduction(models.Model):
|
||||
move.product_id, procurement_qty, move.product_uom,
|
||||
move.location_id, move.name, move.origin, move.company_id, values))
|
||||
update_info.append((move, old_qty, new_qty))
|
||||
else:
|
||||
if move.quantity_done > 0:
|
||||
raise UserError(_('Lines need to be deleted, but can not as you still have some quantities to consume in them. '))
|
||||
move._action_cancel()
|
||||
move_to_unlink |= move
|
||||
|
||||
moves_to_assign._action_assign()
|
||||
move_to_unlink.unlink()
|
||||
if procurements:
|
||||
self.env['procurement.group'].run(procurements)
|
||||
return update_info
|
||||
|
||||
@@ -874,10 +874,10 @@ class TestMrpOrder(TestMrpCommon):
|
||||
mo.move_raw_ids.filtered(lambda m: m.state != 'done')[0].quantity_done = 0
|
||||
update_quantity_wizard.change_prod_qty()
|
||||
|
||||
self.assertEqual(len(mo.move_raw_ids), 2)
|
||||
self.assertEqual(len(mo.move_raw_ids), 4)
|
||||
|
||||
mo.button_mark_done()
|
||||
self.assertTrue(all(s == 'done' for s in mo.move_raw_ids.mapped('state')))
|
||||
self.assertTrue(all(s in ['done', 'cancel'] for s in mo.move_raw_ids.mapped('state')))
|
||||
self.assertEqual(sum(mo.move_raw_ids.mapped('move_line_ids.reserved_uom_qty')), 0)
|
||||
|
||||
def test_consumption_strict_1(self):
|
||||
|
||||
Reference in New Issue
Block a user