[FIX] mrp: prevent traceback while date_finished field is null

While creating a new Manufacturing Orders, if user set value of 'date_finished'
field in the 'Work Orders' as null. As 'date_finished' field is not required,
user might have removed it by using other way.

Traceback will be generated.

'>' not supported between instances of 'bool' and 'datetime.datetime'

This commit will check the condition if the value of 'date_finished' is set or
not.

sentry - 4197616234

closes odoo/odoo#123802

X-original-commit: 11f6f2315159d321180e0fd6c9bc5747c5a7e781
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Preksha Chouhan (prec) <prec@odoo.com>
This commit is contained in:
Preksha Chouhan
2023-06-06 08:06:07 +02:00
parent 577bdbcd87
commit eaf506c27b
+2 -1
View File
@@ -493,7 +493,8 @@ class MrpWorkorder(models.Model):
if workorder.state in ['done', 'cancel']:
continue
workorder._plan_workorder(replan)
date_start = max(date_start, workorder.date_finished)
if workorder.date_finished and workorder.date_finished > date_start:
date_start = workorder.date_finished
# Plan only suitable workorders
if self.state not in ['pending', 'waiting', 'ready']:
return