Merge pull request #14154 from rohitwaghchaure/set_default_leave_approver
Set leave approver in the leave application
This commit is contained in:
commit
1275ea5123
@ -42,6 +42,7 @@ frappe.ui.form.on("Leave Application", {
|
||||
|
||||
employee: function(frm) {
|
||||
frm.trigger("get_leave_balance");
|
||||
frm.trigger("set_leave_approver");
|
||||
},
|
||||
|
||||
leave_type: function(frm) {
|
||||
@ -125,4 +126,21 @@ frappe.ui.form.on("Leave Application", {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
set_leave_approver: function(frm) {
|
||||
if(frm.doc.employee) {
|
||||
// server call is done to include holidays in leave days calculations
|
||||
return frappe.call({
|
||||
method: 'erpnext.hr.doctype.leave_application.leave_application.get_leave_approver_data',
|
||||
args: {
|
||||
"employee": frm.doc.employee,
|
||||
},
|
||||
callback: function(r) {
|
||||
if (r && r.message) {
|
||||
frm.set_value('leave_approver', r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -530,3 +530,8 @@ def add_holidays(events, start, end, employee, company):
|
||||
"title": _("Holiday") + ": " + cstr(holiday.description),
|
||||
"name": holiday.name
|
||||
})
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_leave_approver_data(employee):
|
||||
return frappe.db.get_value("Employee Leave Approver",
|
||||
{'parent': employee}, 'leave_approver')
|
||||
|
Loading…
x
Reference in New Issue
Block a user