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 0b1fc6da84..750120b997 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 @@ from erpnext.accounts.report.cash_flow.cash_flow import (get_cash_flow_accounts, 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 5f1c8830fb..7a6b24658b 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -50,8 +50,11 @@ frappe.ui.form.on("Leave Application", { 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 @@ frappe.ui.form.on("Leave Application", { 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 d0305c3902..c58e0cf5cc 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -374,7 +374,12 @@ def get_leave_details(employee, date): "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 @@ def get_approved_leaves_for_period(employee, leave_type, from_date, to_date): 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')