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:
Mangesh-Khairnar 2019-11-13 19:00:56 +05:30 committed by Nabin Hait
parent 3e515e704d
commit af7fe1937e

View File

@ -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"