[fixes] employee query in leave application
This commit is contained in:
parent
a35466b008
commit
5e50ffa308
@ -335,15 +335,22 @@ def add_holidays(events, start, end, employee, company):
|
|||||||
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
|
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
|
||||||
txt = "%" + cstr(txt) + "%"
|
txt = "%" + cstr(txt) + "%"
|
||||||
|
|
||||||
return webnotes.conn.sql("""select name, employee_name from `tabEmployee` emp
|
if "Leave Approver" in webnotes.user.get_roles():
|
||||||
|
condition = """and (exists(select ela.name from `tabEmployee Leave Approver` ela
|
||||||
|
where ela.parent=`tabEmployee`.name and ela.leave_approver= "%s") or
|
||||||
|
not exists(select ela.name from `tabEmployee Leave Approver` ela
|
||||||
|
where ela.parent=`tabEmployee`.name)
|
||||||
|
or user_id = "%s")""" % (webnotes.session.user, webnotes.session.user)
|
||||||
|
else:
|
||||||
|
from webnotes.widgets.reportview import build_match_conditions
|
||||||
|
condition = build_match_conditions("Employee")
|
||||||
|
condition = ("and " + condition) if condition else ""
|
||||||
|
|
||||||
|
return webnotes.conn.sql("""select name, employee_name from `tabEmployee`
|
||||||
where status = 'Active' and docstatus < 2 and
|
where status = 'Active' and docstatus < 2 and
|
||||||
(`%s` like %s or employee_name like %s) and
|
(`%s` like %s or employee_name like %s) %s
|
||||||
(exists(select ela.name from `tabEmployee Leave Approver` ela
|
|
||||||
where ela.parent=emp.name and ela.leave_approver=%s) or
|
|
||||||
not exists(select ela.name from `tabEmployee Leave Approver` ela where ela.parent=emp.name)
|
|
||||||
or user_id = %s)
|
|
||||||
order by
|
order by
|
||||||
case when name like %s then 0 else 1 end,
|
case when name like %s then 0 else 1 end,
|
||||||
case when employee_name like %s then 0 else 1 end,
|
case when employee_name like %s then 0 else 1 end,
|
||||||
name limit %s, %s""" % tuple([searchfield] + ["%s"]*8),
|
name limit %s, %s""" % tuple([searchfield] + ["%s"]*2 + [condition] + ["%s"]*4),
|
||||||
(txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len))
|
(txt, txt, txt, txt, start, page_len))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user