[Fix] onload set default employee, leave approver, company
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
index 0b1fc6d..750120b 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
@@ -15,6 +15,10 @@
def execute(filters=None):
columns, data, message, chart = [], [], [], []
+
+ if not filters.get('company'):
+ return columns, data, message, chart
+
fiscal_year = get_fiscal_year_data(filters.get('from_fiscal_year'), filters.get('to_fiscal_year'))
companies_column, companies = get_companies(filters)
columns = get_columns(companies_column)
diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js
index 5f1c883..7a6b246 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.js
+++ b/erpnext/hr/doctype/leave_application/leave_application.js
@@ -50,8 +50,11 @@
date: frm.doc.posting_date
},
callback: function(r) {
- if (!r.exc && r.message) {
- leave_details = r.message;
+ if (!r.exc && r.message['leave_allocation']) {
+ leave_details = r.message['leave_allocation'];
+ }
+ if (!r.exc && r.message['leave_approver']) {
+ frm.set_value('leave_approver', r.message['leave_approver']);
}
}
});
@@ -74,6 +77,13 @@
if(frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) {
frm.set_intro(__("Fill the form and save it"));
}
+
+ if (!frm.doc.employee && frappe.defaults.get_user_permissions()) {
+ const perm = frappe.defaults.get_user_permissions();
+ if (perm && perm['Employee']) {
+ frm.set_value('employee', perm['Employee']["docs"][0])
+ }
+ }
},
employee: function(frm) {
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index d0305c3..c58e0cf 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -374,7 +374,12 @@
"pending_leaves": leaves_pending,
"remaining_leaves": remaining_leaves}
- return leave_allocation
+ ret = {
+ 'leave_allocation': leave_allocation,
+ 'leave_approver': get_leave_approver(employee)
+ }
+
+ return ret
@frappe.whitelist()
def get_leave_balance_on(employee, leave_type, date, allocation_records=None,
@@ -603,3 +608,10 @@
return leave_days
+def get_leave_approver(employee, department=None):
+ if not department:
+ department = frappe.db.get_value('Employee', employee, 'department')
+
+ if department:
+ return frappe.db.get_value('Department Approver', {'parent': department,
+ 'parentfield': 'leave_approver', 'idx': 1}, 'approver')