Server Error: TypeError: object of type 'NoneType' has no len() in Employee Leave Balance DocType

, ,

Hi,
I get this Error TypeError: object of type ‘NoneType’ has no len()
in Employee Leave Balance DocType
in
ERPNext: v12.1.4 (version-12)
Frappe Framework: v12.0.14 (version-12)
Please any help!

Hi,
If you are self hosted - on the server check say here frappe-bench/logs/* for the traceback for that error.

Copy and paste it here so all can review and troubleshoot this.

Also if you could describe the context - what you were doing or steps to replicate the problem, that would help.

thanks

A fix may be pending -

This was merged to develop Sept 12 but the build errored fix: leave balance reports by Mangesh-Khairnar · Pull Request #18984 · frappe/erpnext · GitHub

This report on Sept 18 confirms the error persists Leave Balance Report Error · Issue #19100 · frappe/erpnext · GitHub

Your error report Server Error: TypeError: object of type ‘NoneType’ has no len() in Employee Leave Balance DocType · Issue #19160 · frappe/erpnext · GitHub

Nonetheless please post your traceback…

Hi,
thank you for your replay
here is the Error Snapshot “TypeError(“object of type ‘NoneType’ has no len()”,)”

Error Report
Python 2.7.12: /home/frappe/frappe-bench/env/bin/python (prefix: /home/frappe/frappe-bench/env)

Timestamp:
2019-09-25 13:09:30.387630
Relapsed
1
Exception
args (“object of type ‘NoneType’ has no len()”,)
message “object of type ‘NoneType’ has no len()”
Locals
[removed from this snapshot]

Traceback
/home/frappe/frappe-bench/apps/frappe/frappe/app.py: 60

58
59 elif frappe.request.path.startswith(“/api/”):
60 response = frappe.api.handle()
61
62 elif frappe.request.path.startswith(‘/backups’):
Locals
frappe. api
frappe.api. handle
global frappe
response None
/home/frappe/frappe-bench/apps/frappe/frappe/api.py: 55

53 if call==“method”:
54 frappe.local.form_dict.cmd = doctype
55 return frappe.handler.handle()
56
57 elif call==“resource”:
Locals
frappe. handler
frappe.handler. handle
global frappe
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 21

19
20 if cmd!=‘login’:
21 data = execute_cmd(cmd)
22
23 # data can be an empty string or list which are valid responses
Locals
cmd u’frappe.desk.query_report.run’
data None
global execute_cmd
/home/frappe/frappe-bench/apps/frappe/frappe/handler.py: 56

54 is_whitelisted(method)
55
56 return frappe.call(method, **frappe.form_dict)
57
58
Locals
frappe. call
frappe. form_dict {‘cmd’: u’frappe.desk.query_report.run’, ‘filter…ems"}’, ‘report_name’: u’Employee Leave Balance’}
global frappe
method
/home/frappe/frappe-bench/apps/frappe/frappe/init.py: 1036

1034 newargs = get_newargs(fn, kwargs)
1035
1036 return fn(*args, **newargs)
1037
1038 def get_newargs(fn, kwargs):
Locals
args ()
fn
newargs {‘cmd’: u’frappe.desk.query_report.run’, ‘filters’: u’{“from_date”:“2019-01-01”,“to_date”:“2019-12-31”,“company”:“Networld Systems”}‘, ‘report_name’: u’Employee Leave Balance’}
/home/frappe/frappe-bench/apps/frappe/frappe/init.py: 511

509
510 try:
511 retval = fn(*args, **get_newargs(fn, kwargs))
512 except:
513 raise
Locals
args ()
fn
global get_newargs
kwargs {‘cmd’: u’frappe.desk.query_report.run’, ‘filters’: u’{“from_date”:“2019-01-01”,“to_date”:“2019-12-31”,“company”:“Networld Systems”}‘, ‘report_name’: u’Employee Leave Balance’}
retval undefined
/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py: 200

198 result = get_prepared_report_result(report, filters, dn, user)
199 else:
200 result = generate_report_result(report, filters, user)
201
202 result[“add_total_row”] = report.add_total_row
Locals
filters u’{“from_date”:“2019-01-01”,“to_date”:“2019-12-31”,“company”:“XXX Systems”}’
global generate_report_result
report
result None
user u’abc@example.com’
/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py: 75

73 start_time = datetime.datetime.now()
74 # The JOB
75 res = frappe.get_attr(method_name)(frappe._dict(filters))
76
77 end_time = datetime.datetime.now()
Locals
filters {u’company’: u’XXX Systems’, u’from_date’: u’2019-01-01’, u’to_date’: u’2019-12-31’}
frappe. _dict
frappe. get_attr
global frappe
method_name u’erpnext.hr.report.employee_leave_balance.employee_leave_balance.execute’
res []
/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py: 18

16
17 columns = get_columns(leave_types)
18 data = get_data(filters, leave_types)
19
20 return columns, data
Locals
data undefined
filters {u’from_date’: u’2019-01-01’, u’company’: u’XXX Systems’, u’to_date’: u’2019-12-31’}
global get_data
leave_types [u’Casual Leave’, u’Compensatory Off’, u’Leave Without Pay’, u’Marriage Leave’, u’Privilege Leave’, u’\u0627\u0644\u0627\u062c\u0627\u0632\u0629 \u0627\u0644\u0633\u0646\u0648\u064a\u0629’, u’\u0627\u0644\u0627\u062c\u0627\u0632\u0629 \u0627\u0644\u0637\u0627\u0631\u0626\u0629’, u’\u0627\u0644\u0627\u062c\u0627\u0632\u0629 \u0627\u0644\u0645\u0631\u0636\u064a\u0629’]
/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py: 64

62 for employee in active_employees:
63 leave_approvers = department_approver_map.get(employee.department_name, []).append(employee.leave_approver)
64 if (len(leave_approvers) and user in leave_approvers) or (user in [“Administrator”, employee.user_id]) or (“HR Manager” in frappe.get_roles(user)):
65 row = [employee.name, employee.employee_name, employee.department]
66
Locals
builtin len
employee {u’department’: u’Maintenance - NS’, u’leave_app…‘employee_name’: u’Mr Magoo’}
employee. user_id u’m.goo@xxxworldsys.net’
frappe. get_roles
global frappe
leave_approvers None
user u’abc@example.com’

For privacy reasons I removed references to actual names of people, businesses and so on from your error report!

Really I appreciate that,
Thank you

Regarding the scenario , just I open the Employee Leave Balance report
then I face this error pop up TypeError: object of type ‘NoneType’ has no len()

I am getting the same TypeError: object of type ‘NoneType’ has no len() error message

1 Like

nabin just committed a fix to the develop branch
https://github.com/frappe/erpnext/commit/25e043766a3d30c94f2e7a82e1ba437bc6971d9d#diff-64148c7a6569329db6853c40e90d711a

1 Like

Hi i have just updated to V12 from 11 and send emails i get a issue.
in the log it says
File “/usr/lib/python3.5/email/message.py”, line 49, in _formatparam
if value is not None and len(value) > 0:
TypeError: object of type ‘EmailPolicy’ has no len()

Hi i have just updated to V12 from 11 and send emails i get a issue.
i have this issue in the log it says
File “/usr/lib/python3.5/email/message.py”, line 49, in _formatparam
if value is not None and len(value) > 0:
TypeError: object of type ‘EmailPolicy’ has no len()
[/quote]

Facing the same issue after upgrading from V11 to V12