[FIX] mrp: Allow to ajust real duration on workorder operation

Steps:
- Enable `Worder orders` in Manufacturing settings
- Create a manufacturing order with a bill of materials and workorder operation set and confirm
- Go to the workorder tab and start, then finish after few seconds
- Update the real duration
- Try to save

Issue:
User Error

Cause:
When writing on a `mrp.production` object we check if the production is still planned and if, it try
to plan all the workorders which are not done or cancelled. But in our case all the workorders are done
so it try to write to an empty object.

opw-3230310

closes odoo/odoo#116122

X-original-commit: 674f37fbbaa4a0d7f34f8d75d16dd11373815932
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djoumatchoua Eteil Junior (etdj) <etdj@odoo.com>
This commit is contained in:
Eteil Djoumatchoua(etdj)
2023-03-22 09:16:40 +01:00
parent 8259cf76ce
commit cbeaf6ffd4
+3
View File
@@ -1307,6 +1307,9 @@ class MrpProduction(models.Model):
workorder._plan_workorder(replan)
workorders = self.workorder_ids.filtered(lambda w: w.state not in ['done', 'cancel'])
if not workorders:
return
self.with_context(force_date=True).write({
'date_start': min([workorder.leave_id.date_from for workorder in workorders]),
'date_finished': max([workorder.leave_id.date_to for workorder in workorders])