diff --git a/erpnext/hr/doctype/department_approver/department_approver.py b/erpnext/hr/doctype/department_approver/department_approver.py index 9f2f2013a7..7bf9905d07 100644 --- a/erpnext/hr/doctype/department_approver/department_approver.py +++ b/erpnext/hr/doctype/department_approver/department_approver.py @@ -19,14 +19,20 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters): approvers = [] department_details = {} department_list = [] - employee_department = filters.get("department") or frappe.get_value("Employee", filters.get("employee"), "department") + employee = frappe.get_value("Employee", filters.get("employee"), ["department", "leave_approver"], as_dict=True) + if employee.leave_approver: + approver = frappe.db.get_value("User", leave_approver, ['name', 'first_name', 'last_name']) + approvers.append(approver) + return approvers + + employee_department = filters.get("department") or employee.department if employee_department: department_details = frappe.db.get_value("Department", {"name": employee_department}, ["lft", "rgt"], as_dict=True) if department_details: department_list = frappe.db.sql("""select name from `tabDepartment` where lft <= %s and rgt >= %s and disabled=0 - order by lft desc""", (department_details.lft, department_details.rgt), as_list = True) + order by lft desc""", (department_details.lft, department_details.rgt), as_list=True) if filters.get("doctype") == "Leave Application": parentfield = "leave_approvers" @@ -41,4 +47,4 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters): and approver.parentfield = %s and approver.approver=user.name""",(d, "%" + txt + "%", parentfield), as_list=True) - return approvers \ No newline at end of file + return approvers