Commonified functions for retrieving Leave Approvers
This commit is contained in:
parent
33cc081c3b
commit
15343be386
@ -12,8 +12,13 @@ class EmployeeLeaveApprover(Document):
|
||||
pass
|
||||
|
||||
def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
return get_approver_list(filters.get("user"))
|
||||
|
||||
|
||||
def get_approver_list(name):
|
||||
return frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user, tabUserRole user_role where
|
||||
user_role.role = "Leave Approver"
|
||||
and user_role.parent = user.name and
|
||||
user.name != %s
|
||||
and user_role.role = "Leave Approver"
|
||||
and user_role.parent = user.name""", filters.get("user"))
|
||||
""", name)
|
@ -9,6 +9,7 @@ from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_li
|
||||
from erpnext.hr.utils import set_employee_name
|
||||
from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
|
||||
from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee
|
||||
from erpnext.hr.doctype.employee_leave_approver.employee_leave_approver import get_approver_list
|
||||
|
||||
|
||||
class LeaveDayBlockedError(frappe.ValidationError): pass
|
||||
@ -256,12 +257,7 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
and approver.leave_approver=user.name""", (filters.get("employee"), "%" + txt + "%"))
|
||||
|
||||
if not approvers_list:
|
||||
approvers_list = frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user, tabUserRole user_role where
|
||||
user_role.role = "Leave Approver"
|
||||
and user_role.parent = user.name
|
||||
and user.name != %s
|
||||
""", employee_user)
|
||||
approvers_list = get_approver_list(employee_user)
|
||||
return approvers_list
|
||||
|
||||
@frappe.whitelist()
|
||||
|
Loading…
x
Reference in New Issue
Block a user