Set leave approver in the leave application

This commit is contained in:
Rohit Waghchaure 2018-05-20 21:21:33 +05:30
parent b81ece9ddf
commit 812224e56e
2 changed files with 23 additions and 0 deletions

View File

@ -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);
}
}
});
}
}
});

View File

@ -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')