fix: fetch leave approver defined in employee in leave application (#19559)
* fix: fetch leave approver defined in employee in leave application * Update department_approver.py
This commit is contained in:
parent
3e515e704d
commit
af7fe1937e
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user