Error in Production Order

Hello everyone,

I’m getting the error below when submiting a production order with operations, somehow my “planned end date” is not being filled correctly. I’ve already tried to “reset do defaults” but nothing happened.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 19, in savedocs
doc.submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 683, in submit
self._submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 672, in _submit
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 242, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 269, in _save
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 714, in run_before_save_methods
self.run_method(“before_submit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 661, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 839, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 822, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 655, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py”, line 168, in before_submit
self.make_time_logs()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py”, line 271, in make_time_logs
timesheet.validate_time_logs()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py”, line 155, in validate_time_logs
self.check_workstation_timings(data)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py”, line 198, in check_workstation_timings
check_if_within_operating_hours(args.workstation, args.operation, args.from_time, args.to_time)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py”, line 56, in check_if_within_operating_hours
is_within_operating_hours(workstation, operation, from_datetime, to_datetime)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py”, line 63, in is_within_operating_hours
slot_length = (to_timedelta(working_hour.end_time or “”) - to_timedelta(working_hour.start_time or “”)).total_seconds()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 62, in to_timedelta
t = parser.parse(time_str)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py”, line 1164, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py”, line 558, in parse
raise ValueError(“String does not contain a date.”)
ValueError: String does not contain a date.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 882, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 19, in savedocs
doc.submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 683, in submit
self._submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 672, in _submit
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 242, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 269, in _save
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 714, in run_before_save_methods
self.run_method(“before_submit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 661, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 839, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 822, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 655, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py”, line 168, in before_submit
self.make_time_logs()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py”, line 271, in make_time_logs
timesheet.validate_time_logs()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py”, line 155, in validate_time_logs
self.check_workstation_timings(data)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py”, line 198, in check_workstation_timings
check_if_within_operating_hours(args.workstation, args.operation, args.from_time, args.to_time)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py”, line 56, in check_if_within_operating_hours
is_within_operating_hours(workstation, operation, from_datetime, to_datetime)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py”, line 63, in is_within_operating_hours
slot_length = (to_timedelta(working_hour.end_time or “”) - to_timedelta(working_hour.start_time or “”)).total_seconds()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 62, in to_timedelta
t = parser.parse(time_str)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py”, line 1164, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py”, line 558, in parse
raise ValueError(“String does not contain a date.”)
ValueError: String does not contain a date.

any ideas?

Hi @applepipe,

Can you check the working hours has set properly in all workstations.

Hello @rohit_w, thanks for replying.

Apparently everything is set properly, here are my screenshots:

If I delete the operation time, it doesnt save, the error just shows when submiting.

I deactivated capacity planing for now and its working, but no solution so far

Reactivated capacity planning, and allowed over hours, all working with planned end date filled automatic, if I do not allow over hours the error shows up again.

Hi @applepipe,

Thanks, I’ll check the issue

Copy of the error snapshot:

Error Report

Python 2.7.6: /home/frappe/frappe-bench/env/bin/python (prefix: /home/frappe/frappe-bench/env)

Timestamp:
2016-09-26 23:03:26.289930
Reincidente
1
Exceção

args (u’String does not contain a date.',)
message String does not contain a date.
Locals

default datetime.datetime(2016, 9, 26, 0, 0)
effective_dt datetime.datetime(2016, 9, 26, 23, 3, 26, 271336)
ignoretz False
kwargs {}
res _result()
self
skipped_tokens None
timestr u’’
tzinfos None
Traceback

/home/frappe/frappe-bench/apps/frappe/frappe/app.py: 55

53
54 if frappe.local.form_dict.cmd:
55 response = frappe.handler.handle()
56
57 elif frappe.request.path.startswith(“/api/”):
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 19

17
18 if cmd!=‘login’:
19 execute_cmd(cmd)
20
21 return build_response(“json”)
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 36

34 is_whitelisted(method)
35
36 ret = frappe.call(method, **frappe.form_dict)
37
38 # returns with a message
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/init.py: 884

882 del newargs[“flags”]
883
884 return fn(*args, **newargs)
885
886 def make_property_setter(args, ignore_validate=False, validate_fields_for_doctype=True):
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py: 19

17
18 if doc.docstatus==1:
19 doc.submit()
20 else:
21 try:
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 683

681 def submit(self):
682 “”“Submit the document. Sets docstatus = 1, then saves.”“”
683 self._submit()
684
685 @whitelist.func
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 672

670 “”“Submit the document. Sets docstatus = 1, then saves.”“”
671 self.docstatus = 1
672 self.save()
673
674 @whitelist.func
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 242

240 def save(self, *args, **kwargs):
241 “”“Wrapper for _save”“”
242 return self._save(*args, **kwargs)
243
244 def _save(self, ignore_permissions=None):
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 269

267 self.set_parent_in_children()
268 self.validate_higher_perm_levels()
269 self.run_before_save_methods()
270
271 if self._action != “cancel”:
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 714

712 elif self._action==“submit”:
713 self.run_method(“validate”)
714 self.run_method(“before_submit”)
715 elif self._action==“cancel”:
716 self.run_method(“before_cancel”)
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 661

659
660 fn.name = method.encode(“utf-8”)
661 return Document.hook(fn)(self, *args, **kwargs)
662
663 @staticmethod
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 839

837
838 composed = compose(f, *hooks)
839 return composed(self, method, *args, **kwargs)
840
841 return composer
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 822

820 def compose(fn, *hooks):
821 def runner(self, method, *args, **kwargs):
822 add_to_return_value(self, fn(self, *args, **kwargs))
823 for f in hooks:
824 add_to_return_value(self, f(self, method, *args, **kwargs))
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py: 655

653
654 if hasattr(self, method) and hasattr(getattr(self, method), “call”):
655 fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
656 else:
657 # hack! to run hooks even if method does not exist
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py: 168

166 def before_submit(self):
167 self.set_required_items()
168 self.make_time_logs()
169
170 def on_submit(self):
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/production_order/production_order.py: 271

269 # validate operating hours if workstation [not mandatory] is specified
270 try:
271 timesheet.validate_time_logs()
272 except OverlapError:
273 if frappe.message_log: frappe.message_log.pop()
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py: 171

169 def validate_time_logs(self):
170 for data in self.get(‘time_logs’):
171 self.check_workstation_timings(data)
172 self.validate_overlap(data)
173
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/projects/doctype/timesheet/timesheet.py: 214

212 “”“Checks if Time Log is between operating hours of the Workstation.”“”
213 if args.workstation and args.from_time and args.to_time:
214 check_if_within_operating_hours(args.workstation, args.operation, args.from_time, args.to_time)
215
216 def schedule_for_production_order(self, index):
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py: 56

54
55 if not cint(frappe.db.get_value(“Manufacturing Settings”, None, “allow_overtime”)):
56 is_within_operating_hours(workstation, operation, from_datetime, to_datetime)
57
58 def is_within_operating_hours(workstation, operation, from_datetime, to_datetime):
Locals
/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/workstation/workstation.py: 63

61
62 for working_hour in workstation.working_hours:
63 slot_length = (to_timedelta(working_hour.end_time or “”) - to_timedelta(working_hour.start_time or “”)).total_seconds()
64 if slot_length >= operation_length:
65 return
Locals
/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py: 62

60 def to_timedelta(time_str):
61 if isinstance(time_str, basestring):
62 t = parser.parse(time_str)
63 return datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second, microseconds=t.microsecond)
64
Locals
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py: 1164

1162 return parser(parserinfo).parse(timestr, **kwargs)
1163 else:
1164 return DEFAULTPARSER.parse(timestr, **kwargs)
1165
1166
Locals
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/dateutil/parser.py: 558

556
557 if len(res) == 0:
558 raise ValueError(“String does not contain a date.”)
559
560 repl = {}