Merge pull request #3351 from anandpdoshi/anand-may-26-production-fixes

[fix] workstation fixes related to Production Order
This commit is contained in:
Rushabh Mehta 2015-05-27 15:09:47 +05:30
commit 78f137890c
2 changed files with 9 additions and 7 deletions

View File

@ -220,7 +220,9 @@ class ProductionOrder(Document):
time_log = make_time_log(self.name, d.operation, d.planned_start_time, d.planned_end_time, time_log = make_time_log(self.name, d.operation, d.planned_start_time, d.planned_end_time,
flt(self.qty) - flt(d.completed_qty), self.project_name, d.workstation, operation_id=d.name) flt(self.qty) - flt(d.completed_qty), self.project_name, d.workstation, operation_id=d.name)
self.check_operation_fits_in_working_hours(d) if d.workstation:
# validate operating hours if workstation [not mandatory] is specified
self.check_operation_fits_in_working_hours(d)
original_start_time = time_log.from_time original_start_time = time_log.from_time
while True: while True:

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.utils import flt, cint, getdate, formatdate, comma_and, time_diff_in_seconds, get_datetime from frappe.utils import flt, cint, getdate, formatdate, comma_and, time_diff_in_seconds, to_timedelta
from frappe.model.document import Document from frappe.model.document import Document
from dateutil.parser import parse from dateutil.parser import parse
@ -60,7 +60,7 @@ def is_within_operating_hours(workstation, operation, from_datetime, to_datetime
workstation = frappe.get_doc("Workstation", workstation) workstation = frappe.get_doc("Workstation", workstation)
for working_hour in workstation.working_hours: for working_hour in workstation.working_hours:
slot_length = (get_datetime(working_hour.end_time) - get_datetime(working_hour.start_time)).total_seconds() slot_length = (to_timedelta(working_hour.end_time or "") - to_timedelta(working_hour.start_time or "")).total_seconds()
if slot_length >= operation_length: if slot_length >= operation_length:
return return