Merge pull request #14154 from rohitwaghchaure/set_default_leave_approver

Set leave approver in the leave application
This commit is contained in:
rohitwaghchaure 2018-05-21 11:58:41 +05:30 committed by GitHub
commit 1275ea5123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -42,6 +42,7 @@ frappe.ui.form.on("Leave Application", {
employee: function(frm) { employee: function(frm) {
frm.trigger("get_leave_balance"); frm.trigger("get_leave_balance");
frm.trigger("set_leave_approver");
}, },
leave_type: function(frm) { 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), "title": _("Holiday") + ": " + cstr(holiday.description),
"name": holiday.name "name": holiday.name
}) })
@frappe.whitelist()
def get_leave_approver_data(employee):
return frappe.db.get_value("Employee Leave Approver",
{'parent': employee}, 'leave_approver')