From d0839799c1fc3ec6da6cda701a9d4699b4fcb168 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 26 Nov 2016 09:54:00 +0530 Subject: [PATCH] Update workstation.py --- erpnext/manufacturing/doctype/workstation/workstation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index b939803ad0f..50957841921 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -60,9 +60,10 @@ def is_within_operating_hours(workstation, operation, from_datetime, to_datetime workstation = frappe.get_doc("Workstation", workstation) for working_hour in workstation.working_hours: - slot_length = (to_timedelta(working_hour.end_time or "") - to_timedelta(working_hour.start_time or "")).total_seconds() - if slot_length >= operation_length: - return + if working_hour.start_time and working_hour.end_time: + slot_length = (to_timedelta(working_hour.end_time or "") - to_timedelta(working_hour.start_time or "")).total_seconds() + if slot_length >= operation_length: + return frappe.throw(_("Operation {0} longer than any available working hours in workstation {1}, break down the operation into multiple operations").format(operation, workstation.name), NotInWorkingHoursError)