diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index f69087811b..b39530097e 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -258,13 +258,11 @@ class ProductionOrder(Document): timesheet = make_timesheet(self.name) workstation_list = [] - last_workstation_idx = {} timesheet.set('time_logs', []) for i, d in enumerate(self.operations): if d.workstation and d.status != 'Completed': - last_workstation_idx[d.workstation] = i # set last row index of workstation - self.set_start_end_time_for_workstation(d, workstation_list, last_workstation_idx.get(d.workstation)) + self.set_start_end_time_for_workstation(d, workstation_list, i) args = self.get_operations_data(d) add_timesheet_detail(timesheet, args) @@ -318,9 +316,8 @@ class ProductionOrder(Document): """Set start and end time for given operation. If first operation, set start as `planned_start_date`, else add time diff to end time of earlier operation.""" - if data.workstation not in workstation_list: + if index == 0: data.planned_start_time = self.planned_start_date - workstation_list.append(data.workstation) else: data.planned_start_time = get_datetime(self.operations[index-1].planned_end_time)\ + get_mins_between_operations()