feat: Added default Leave Approver in Employee (#18953)
diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json
index 5202218..ee0b2a2 100644
--- a/erpnext/hr/doctype/employee/employee.json
+++ b/erpnext/hr/doctype/employee/employee.json
@@ -7,6 +7,7 @@
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 1,
+ "engine": "InnoDB",
"field_order": [
"basic_information",
"employee",
@@ -54,6 +55,7 @@
"column_break_44",
"holiday_list",
"default_shift",
+ "leave_approver",
"salary_information",
"salary_mode",
"bank_name",
@@ -767,12 +769,18 @@
"fieldtype": "Link",
"label": "Default Shift",
"options": "Shift Type"
+ },
+ {
+ "fieldname": "leave_approver",
+ "fieldtype": "Link",
+ "label": "Leave Approver",
+ "options": "User"
}
],
"icon": "fa fa-user",
"idx": 24,
"image_field": "image",
- "modified": "2019-06-01 16:05:55.132180",
+ "modified": "2019-09-06 15:54:36.735147",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 0aa8849..d4da9c1 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -745,10 +745,12 @@
return leave_days
@frappe.whitelist()
-def get_leave_approver(employee, department=None):
- if not department:
- department = frappe.db.get_value('Employee', employee, 'department')
+def get_leave_approver(employee):
+ leave_approver, department = frappe.db.get_value("Employee",
+ employee, ["leave_approver", "department"])
- if department:
- return frappe.db.get_value('Department Approver', {'parent': department,
- 'parentfield': 'leave_approvers', 'idx': 1}, 'approver')
\ No newline at end of file
+ if not leave_approver and department:
+ leave_approver = frappe.db.get_value('Department Approver', {'parent': department,
+ 'parentfield': 'leave_approvers', 'idx': 1}, 'approver')
+
+ return leave_approver
\ No newline at end of file