[hotfix] check minimum actual start time and actual end time before updating PO Operations (#11041)

* [hotfix] check minimum actual start time and actual end time before updating PO Operations

* Update production_order.py
This commit is contained in:
Makarand Bauskar 2017-10-04 14:30:12 +05:30 committed by Nabin Hait
parent f6580268e6
commit d17bea0a31

View File

@ -370,8 +370,13 @@ class ProductionOrder(Document):
self.actual_start_date = None
self.actual_end_date = None
if self.get("operations"):
self.actual_start_date = min([d.actual_start_time for d in self.get("operations") if d.actual_start_time])
self.actual_end_date = max([d.actual_end_time for d in self.get("operations") if d.actual_end_time])
actual_start_dates = [d.actual_start_time for d in self.get("operations") if d.actual_start_time]
if actual_start_dates:
self.actual_start_date = min(actual_start_dates)
actual_end_dates = [d.actual_end_time for d in self.get("operations") if d.actual_end_time]
if actual_end_dates:
self.actual_end_date = max(actual_end_dates)
def delete_timesheet(self):
for timesheet in frappe.get_all("Timesheet", ["name"], {"production_order": self.name}):
@ -621,4 +626,4 @@ def stop_unstop(production_order, status):
frappe.msgprint(_("Production Order has been {0}").format(status))
pro_order.notify_update()
return pro_order.status
return pro_order.status