Update actual dates in Production Order from Timesheet

This commit is contained in:
Nabin Hait 2017-09-13 15:13:53 +05:30
parent c9e96c15af
commit c443c9f05d

View File

@ -367,15 +367,11 @@ class ProductionOrder(Document):
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
def set_actual_dates(self):
self.actual_start_date = None
self.actual_end_date = None
if self.get("operations"):
actual_date = frappe.db.sql("""select min(actual_start_time) as start_date,
max(actual_end_time) as end_date from `tabProduction Order Operation`
where parent = %s and docstatus=1""", self.name, as_dict=1)[0]
self.actual_start_date = actual_date.start_date
self.actual_end_date = actual_date.end_date
else:
self.actual_start_date = None
self.actual_end_date = None
self.actual_start_date = min([d.actual_start_time for d in self.get("operations")])
self.actual_end_date = max([d.actual_end_time for d in self.get("operations")])
def delete_timesheet(self):
for timesheet in frappe.get_all("Timesheet", ["name"], {"production_order": self.name}):