HR Module error logs seem to be a bug?


Is this a bug - on a fresh install on erpnext v12 im getting error logs


{‘event’: u’daily_long’, ‘retry’: 0, ‘log’: <function log at 0x7f8183b146e0>, ‘site’: u’’, ‘job_name’: u’’, ‘method_name’: u’’, ‘method’: <function process_expired_allocation at 0x7f81838a4488>, ‘user’: u’Administrator’, ‘kwargs’: {}, ‘is_async’: True}
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 99, in execute_job
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/leave_ledger_entry/”, line 119, in process_expired_allocation
if expire_allocation:
UnboundLocalError: local variable ‘expire_allocation’ referenced before assignment

Am I missing a tick box or config somewhere?

Kind regards

1 Like

I am getting the same thing, Fresh v12 install.

Same here. I am getting this error.

“Am I missing a tick box or config somewhere?”

No it seems the error occurs since expire_allocation is not assigned on line # 107 since that code is ‘out of scope’ of the code that begins on line # 98 ‘if leave_type_records:’

What you could try: Move line #s 119 and 120 within the scope by indenting them so that they will be assigned

like this:

		expire_allocation = frappe.get_all("Leave Ledger Entry",
			fields=['leaves', 'to_date', 'employee', 'leave_type', 'is_carry_forward', 'transaction_name as name', 'transaction_type'],
				'to_date': ("<", today()),
				'transaction_type': 'Leave Allocation',
				'transaction_name': ('not in', expired_allocation)
				'is_carry_forward': 0,
				'leave_type': ('in', leave_type)

       	if expire_allocation:

Is that the case of what do you suggest @mangesh_khairnar? I see this commit to 12.0.8 a few weeks ago fix: check for old unexpired allocation · frappe/erpnext@3146475 · GitHub

I have added a fix for the same in this PR: fix: process allocation expiry by Mangesh-Khairnar · Pull Request #18853 · frappe/erpnext · GitHub.