From 80fb0bf520ea43fa1000601ae27a299e05b31db2 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 3 Jul 2019 13:06:46 +0530 Subject: [PATCH] fix: add employee leave balance report to the dashboard --- .../doctype/leave_allocation/leave_allocation.js | 8 -------- .../leave_allocation/leave_allocation_dashboard.py | 5 +++++ .../doctype/leave_application/leave_application.js | 10 ---------- .../doctype/leave_application/leave_application.py | 2 +- .../leave_application_dashboard.py | 14 ++++++++++++++ erpnext/patches.txt | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 erpnext/hr/doctype/leave_application/leave_application_dashboard.py diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.js b/erpnext/hr/doctype/leave_allocation/leave_allocation.js index 8f734ac1bc8..2a26a85fa9b 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.js +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.js @@ -30,14 +30,6 @@ frappe.ui.form.on("Leave Allocation", { frm.trigger("expire_allocation"); }); } - - // opens leave balance report for employee - frm.add_custom_button(__('Leave Balance'), function() { - frappe.route_options = { - employee: frm.doc.employee, - }; - frappe.set_route("query-report", "Employee Leave Balance"); - }); } }, diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation_dashboard.py b/erpnext/hr/doctype/leave_allocation/leave_allocation_dashboard.py index 72a1b7c1948..7456aebb457 100644 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation_dashboard.py +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation_dashboard.py @@ -12,4 +12,9 @@ def get_data(): 'items': ['Leave Encashment'] } ], + 'reports': [ + { + 'items': ['Employee Leave Balance'] + } + ] } \ No newline at end of file diff --git a/erpnext/hr/doctype/leave_application/leave_application.js b/erpnext/hr/doctype/leave_application/leave_application.js index 44a60b02598..a755b576082 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.js +++ b/erpnext/hr/doctype/leave_application/leave_application.js @@ -85,16 +85,6 @@ frappe.ui.form.on("Leave Application", { frm.set_value('employee', perm['Employee'].map(perm_doc => perm_doc.doc)[0]); } } - - if (frm.doc.docstatus === 1) { - frm.add_custom_button(__('Leave Balance'), function() { - frappe.route_options = { - employee: frm.doc.employee, - group_by: "" - }; - frappe.set_route("query-report", "Employee Leave Balance"); - }); - } }, employee: function(frm) { diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 74862fb0112..86d9130aab8 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -438,7 +438,7 @@ def get_leave_details(employee, date): @frappe.whitelist() def get_leave_balance_on(employee, leave_type, date, to_date=nowdate(), consider_all_leaves_in_the_allocation_period=False): ''' - Returns leave balance on date + Returns leave balance till date :param employee: employee name :param leave_type: leave type :param date: date to check balance on diff --git a/erpnext/hr/doctype/leave_application/leave_application_dashboard.py b/erpnext/hr/doctype/leave_application/leave_application_dashboard.py new file mode 100644 index 00000000000..8075b7b5c57 --- /dev/null +++ b/erpnext/hr/doctype/leave_application/leave_application_dashboard.py @@ -0,0 +1,14 @@ +from __future__ import unicode_literals + +from frappe import _ + + +def get_data(): + return { + 'reports': [ + { + 'label': _('Reports'), + 'items': ['Employee Leave Balance'] + } + ] + } \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 3b4cfd835db..b3aeab68f21 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -606,7 +606,6 @@ execute:frappe.delete_doc_if_exists("Page", "support-analytics") erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019 execute:frappe.delete_doc_if_exists("Page", "support-analytics") erpnext.patches.v12_0.make_item_manufacturer -erpnext.patches.v12_0.generate_leave_ledger_entries erpnext.patches.v11_1.move_customer_lead_to_dynamic_column erpnext.patches.v11_1.set_default_action_for_quality_inspection erpnext.patches.v11_1.delete_bom_browser @@ -617,3 +616,4 @@ erpnext.patches.v11_1.set_missing_opportunity_from erpnext.patches.v12_0.set_quotation_status erpnext.patches.v12_0.set_priority_for_support erpnext.patches.v12_0.delete_priority_property_setter +erpnext.patches.v12_0.generate_leave_ledger_entries #