'Capacity Planning. Plan time logs based on earliest availablity of workstation after
Planned Start Date. Time logs will be created and remain in Draft mode and must be submitted
before manufacturing entry can be made.'

def make_time_logs(self, open_new=False):

    if (not self.operations):
        return
    timesheets = []
    plan_days = (frappe.db.get_single_value(u'Manufacturing    Settings', u'capacity_planning_for_days') or 30)
    timesheet = make_timesheet(self.name, self.company)
    timesheet.set(u'time_logs', [])
    for (i, d) in enumerate(self.operations):
        if (d.status != u'Completed'):
            self.set_start_end_time_for_workstation(d, i)
            args = self.get_operations_data(d)
            add_timesheet_detail(timesheet, args)
            original_start_time = d.planned_start_time
            try:
                timesheet.validate_time_logs()
            except OverlapError:
                if frappe.message_log:
                    frappe.message_log.pop()
                timesheet.schedule_for_production_order(d.idx)
            except WorkstationHolidayError:
                if frappe.message_log:
                    frappe.message_log.pop()
                timesheet.schedule_for_production_order(d.idx)
            (from_time, to_time) = self.get_start_end_time(timesheet, d.name)
            if (date_diff(from_time, original_start_time) > plan_days):
                frappe.throw(_(u'Unable    to    find    Time    Slot    in    the    next    {0}    days    for    Operation    {1}').format(plan_days, d.operation))
                break
            d.planned_start_time = from_time
            d.planned_end_time = to_time
            d.db_update()
    if (timesheet and open_new):
        return timesheet
    if (timesheet and timesheet.get(u'time_logs')):
        timesheet.save()
        timesheets.append(getlink(u'Timesheet', timesheet.name))
    self.planned_end_date = self.operations[(-1)].planned_end_time
    if timesheets:
        frappe.local.message_log = []
        frappe.msgprint(((_(u'Timesheet    created:') + u'\n') + u'\n'.join(timesheets)))
