[FIX] mrp: copying production order copy all moves

Before this commit, only the moves raw were copied on production
duplication. As the finished move is created normally in an onchange,
this means a production order duplicated have not any move finished.

Task : 2278147
This commit is contained in:
William Henrotin
2020-08-10 09:40:24 +00:00
parent 57f243bcbb
commit 68f06c7acc
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -185,7 +185,7 @@ class MrpProduction(models.Model):
domain=[('scrapped', '=', False)])
move_finished_ids = fields.One2many(
'stock.move', 'production_id', 'Finished Products',
copy=False, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
copy=True, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
domain=[('scrapped', '=', False)])
move_byproduct_ids = fields.One2many('stock.move', compute='_compute_move_byproduct_ids', inverse='_set_move_byproduct_ids')
finished_move_line_ids = fields.One2many(
+19
View File
@@ -1312,3 +1312,22 @@ class TestMrpOrder(TestMrpCommon):
self.assertEqual(mo.move_finished_ids.state, 'done')
self.assertEqual(mo.move_finished_ids.quantity_done, 1)
self.assertEqual(component.qty_available, 13)
def test_copy(self):
""" Check that copying a done production, create all the stock moves"""
mo, bom, p_final, p1, p2 = self.generate_mo(qty_final=1, qty_base_1=1, qty_base_2=1)
mo.action_confirm()
mo_form = Form(mo)
mo_form.qty_producing = 1
mo = mo_form.save()
mo.button_mark_done()
self.assertEqual(mo.state, 'done')
mo_copy = mo.copy()
self.assertTrue(mo_copy.move_raw_ids)
self.assertTrue(mo_copy.move_finished_ids)
mo_copy.action_confirm()
mo_form = Form(mo_copy)
mo_form.qty_producing = 1
mo_copy = mo_form.save()
mo_copy.button_mark_done()
self.assertEqual(mo_copy.state, 'done')