Merge PR #1429 into 17.0

Signed-off-by LoisRForgeFlow
This commit is contained in:
OCA-git-bot
2024-12-27 08:12:19 +00:00
5 changed files with 26 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ Contributors
------------
- David Jiménez <david.jimenez@forgeflow.com>
- Meritxell Abellan <meritxell.abellan@forgeflow.com>
Maintainers
-----------

View File

@@ -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")

View File

@@ -1 +1,2 @@
- David Jiménez \<<david.jimenez@forgeflow.com>\>
- Meritxell Abellan \<<meritxell.abellan@forgeflow.com>\>

View File

@@ -403,6 +403,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>David Jiménez &lt;<a class="reference external" href="mailto:david.jimenez&#64;forgeflow.com">david.jimenez&#64;forgeflow.com</a>&gt;</li>
<li>Meritxell Abellan &lt;<a class="reference external" href="mailto:meritxell.abellan&#64;forgeflow.com">meritxell.abellan&#64;forgeflow.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">

View File

@@ -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()