diff --git a/mrp_production_back_to_draft/README.rst b/mrp_production_back_to_draft/README.rst index abb109e91..c3443af8b 100644 --- a/mrp_production_back_to_draft/README.rst +++ b/mrp_production_back_to_draft/README.rst @@ -57,6 +57,7 @@ Contributors ------------ - David Jiménez +- Meritxell Abellan Maintainers ----------- diff --git a/mrp_production_back_to_draft/models/mrp_production.py b/mrp_production_back_to_draft/models/mrp_production.py index 500d6e4a7..1b79e1ba5 100644 --- a/mrp_production_back_to_draft/models/mrp_production.py +++ b/mrp_production_back_to_draft/models/mrp_production.py @@ -22,6 +22,7 @@ class MrpProduction(models.Model): else: (rec.move_raw_ids + rec.move_finished_ids)._action_cancel() (rec.move_raw_ids + rec.move_finished_ids).write({"state": "draft"}) + rec.workorder_ids.write({"state": "waiting"}) if rec.state != "draft": raise UserError( _("Could not set the production order back to draft") diff --git a/mrp_production_back_to_draft/readme/CONTRIBUTORS.md b/mrp_production_back_to_draft/readme/CONTRIBUTORS.md index ac18283b8..c172ebacf 100644 --- a/mrp_production_back_to_draft/readme/CONTRIBUTORS.md +++ b/mrp_production_back_to_draft/readme/CONTRIBUTORS.md @@ -1 +1,2 @@ - David Jiménez \<\> +- Meritxell Abellan \<\> diff --git a/mrp_production_back_to_draft/static/description/index.html b/mrp_production_back_to_draft/static/description/index.html index a3a0d3391..5df8c2a93 100644 --- a/mrp_production_back_to_draft/static/description/index.html +++ b/mrp_production_back_to_draft/static/description/index.html @@ -403,6 +403,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Contributors

diff --git a/mrp_production_back_to_draft/tests/test_mrp_return_to_draft.py b/mrp_production_back_to_draft/tests/test_mrp_return_to_draft.py index 1505b7598..a770deb53 100644 --- a/mrp_production_back_to_draft/tests/test_mrp_return_to_draft.py +++ b/mrp_production_back_to_draft/tests/test_mrp_return_to_draft.py @@ -61,27 +61,48 @@ class TestMrpProductionAutovalidate(common.TransactionCase): "bom_id": cls.test_bom_1.id, } ) + cls.workcenter_id = cls.env["mrp.workcenter"].create( + { + "name": "Workcenter 01", + } + ) + cls.test_workorder_1 = cls.env["mrp.workorder"].create( + { + "name": "Workorder Test", + "product_uom_id": cls.prod_tp1.uom_id.id, + "production_id": cls.mo_1.id, + "workcenter_id": cls.workcenter_id.id, + "qty_remaining": 1, + "qty_produced": 0, + } + ) def test_01_mrp_return_to_draft(self): self.env["stock.quant"]._update_available_quantity( self.prod_ti1, self.location, 2 ) self.assertEqual(self.mo_1.state, "draft") + self.assertEqual(self.mo_1.workorder_ids.state, "waiting") self.mo_1._compute_move_raw_ids() self.mo_1.action_confirm() self.assertEqual(self.mo_1.state, "confirmed") + self.assertEqual(self.mo_1.workorder_ids.state, "ready") self.mo_1.action_return_to_draft() self.assertEqual(self.mo_1.state, "draft") + self.assertEqual(self.mo_1.workorder_ids.state, "waiting") self.mo_1._compute_move_raw_ids() self.mo_1.action_confirm() self.assertEqual(self.mo_1.state, "confirmed") + self.assertEqual(self.mo_1.workorder_ids.state, "ready") self.mo_1.action_cancel() self.assertEqual(self.mo_1.state, "cancel") + self.assertEqual(self.mo_1.workorder_ids.state, "cancel") self.mo_1.action_return_to_draft() self.assertEqual(self.mo_1.state, "draft") + self.assertNotIn(self.mo_1.workorder_ids.state, ["cancel"]) self.mo_1._compute_move_raw_ids() self.mo_1.action_confirm() self.mo_1.qty_producing = 2 - self.assertEqual(self.mo_1.state, "to_close") + self.mo_1.workorder_ids.action_mark_as_done() with self.assertRaises(UserError): self.mo_1.action_return_to_draft()