From 7fc1bc0b27b96fcc83aa8f29bbee871354dfe051 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Tue, 19 Mar 2019 18:14:02 +0530 Subject: [PATCH] fix: handle an empty match query condition in leave application (#16931) --- erpnext/hr/doctype/leave_application/leave_application.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index b85f38b295e..692db8e1a54 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -505,8 +505,6 @@ def add_department_leaves(events, start, end, employee, company): def add_leaves(events, start, end, filter_conditions=None): conditions = [] - if filter_conditions: - conditions.append(filter_conditions) if not cint(frappe.db.get_value("HR Settings", None, "show_leaves_of_all_department_members_in_calendar")): from frappe.desk.reportview import build_match_conditions @@ -520,11 +518,14 @@ def add_leaves(events, start, end, filter_conditions=None): from `tabLeave Application` where from_date <= %(end)s and to_date >= %(start)s <= to_date and docstatus < 2 - and status!="Rejected" """ + and status!='Rejected' """ if conditions: query += ' and ' + ' and '.join(conditions) + if filter_conditions: + query += filter_conditions + for d in frappe.db.sql(query, {"start":start, "end": end}, as_dict=True): e = { "name": d.name,