[FIX] mrp: prevent the unplan of a single work order

Steps to reproduce the bug:
Go to a work order that is ready or waiting,  try manually changing the scheduled start or end date > save

Problem:
Traceback is triggered because when we modify the date, we check if the start date is before the end date. But we cannot compare a False with a date

opw-2768054

closes odoo/odoo#85991

X-original-commit: 1768a072fd40d14dc8c402c3ccad9a6733460c03
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
Touati Djamel (otd)
2022-03-08 14:58:56 +00:00
parent 9b3decf5f4
commit eb76b725ed
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -2184,6 +2184,14 @@ msgstr ""
msgid "It has already been unblocked."
msgstr ""
#. module: mrp
#: code:addons/mrp/models/mrp_workorder.py:0
#, python-format
msgid ""
"It is not possible to unplan one single Work Order. You should unplan the "
"Manufacturing Order instead in order to unplan all the linked operations."
msgstr ""
#. module: mrp
#: model:ir.model.fields,field_description:mrp.field_mrp_production__is_planned
msgid "Its Operations are Planned"
+3
View File
@@ -252,6 +252,9 @@ class MrpWorkorder(models.Model):
workorder.date_planned_finished = workorder.leave_id.date_to
def _set_dates_planned(self):
if self.leave_id and (not self[0].date_planned_start or not self[0].date_planned_finished):
raise UserError(_("It is not possible to unplan one single Work Order. "
"You should unplan the Manufacturing Order instead in order to unplan all the linked operations."))
date_from = self[0].date_planned_start
date_to = self[0].date_planned_finished
self.mapped('leave_id').sudo().write({