Set leave approver in the leave application
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 06eee61..b335717 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -42,6 +42,7 @@
employee: function(frm) {
frm.trigger("get_leave_balance");
+ frm.trigger("set_leave_approver");
},
leave_type: function(frm) {
@@ -125,4 +126,21 @@
});
}
},
+
+ 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);
+ }
+ }
+ });
+ }
+ }
});
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 4e1b54b..83079d4 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -530,3 +530,8 @@
"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')