[leave application] [employee query] allow employee lookup for which the current user is leave approver or thhe employee has no leave approvers mentioned or the user is the employee
This commit is contained in:
parent
b41bb5de2a
commit
a7b8f35539
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
cur_frm.add_fetch('employee','employee_name','employee_name');
|
cur_frm.add_fetch('employee','employee_name','employee_name');
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, dt, dn) {
|
cur_frm.cscript.onload = function(doc, dt, dn) {
|
||||||
if(!doc.posting_date)
|
if(!doc.posting_date)
|
||||||
set_multiple(dt,dn,{posting_date:get_today()});
|
set_multiple(dt,dn,{posting_date:get_today()});
|
||||||
@ -127,4 +126,8 @@ cur_frm.cscript.calculate_total_days = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;
|
cur_frm.fields_dict.employee.get_query = function() {
|
||||||
|
return {
|
||||||
|
query: "hr.doctype.leave_application.leave_application.query_for_permitted_employees"
|
||||||
|
};
|
||||||
|
}
|
@ -330,3 +330,20 @@ def add_holidays(events, start, end, employee, company):
|
|||||||
"title": _("Holiday") + ": " + cstr(holiday.description),
|
"title": _("Holiday") + ": " + cstr(holiday.description),
|
||||||
"name": holiday.name
|
"name": holiday.name
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def query_for_permitted_employees(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
txt = cstr(txt) + "%"
|
||||||
|
|
||||||
|
return webnotes.conn.sql("""select name, employee_name from `tabEmployee` emp
|
||||||
|
where status = 'Active' and docstatus < 2 and
|
||||||
|
(`%s` like %s or employee_name like %s) and
|
||||||
|
(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
|
||||||
|
case when 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),
|
||||||
|
(txt, txt, webnotes.session.user, webnotes.session.user, txt, txt, start, page_len), debug=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user