From aa6f00c403a115877ff43f329f1b4eaec8e8f320 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Thu, 6 Apr 2017 12:38:13 +0530 Subject: [PATCH] Added default 'All' option to filters to differentiate all and empty filter --- .../employee_attendance_tool.js | 1 + .../employee_attendance_tool.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js index de8e17c366f..c0c0ef0fe04 100644 --- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -4,6 +4,7 @@ frappe.ui.form.on("Employee Attendance Tool", { }, onload: function(frm) { + frm.doc.department = frm.doc.branch = frm.doc.company = "All"; frm.set_value("date", get_today()); erpnext.employee_attendance_tool.load_employees(frm); }, diff --git a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py index 74387370282..6ddb722c1b0 100644 --- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py +++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py @@ -13,11 +13,18 @@ class EmployeeAttendanceTool(Document): @frappe.whitelist() -def get_employees(date, department=None, branch=None, company=None): +def get_employees(date, department = None, branch = None, company = None): attendance_not_marked = [] attendance_marked = [] - employee_list = frappe.get_list("Employee", fields=["employee", "employee_name"], filters={ - "status": "Active", "department": department, "branch": branch, "company": company}, order_by="employee_name") + filters = {"status": "Active"} + if department != "All": + filters["department"] = department + if branch != "All": + filters["branch"] = branch + if company != "All": + filters["company"] = company + + employee_list = frappe.get_list("Employee", fields=["employee", "employee_name"], filters=filters, order_by="employee_name") marked_employee = {} for emp in frappe.get_list("Attendance", fields=["employee", "status"], filters={"attendance_date": date}):