diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index a51e2b5315..c6a92cad33 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -408,13 +408,13 @@ def add_leaves(events, start, end, match_conditions=None): query = """select name, from_date, to_date, employee_name, half_day, status, employee, docstatus from `tabLeave Application` where - (from_date between %s and %s or to_date between %s and %s) + from_date <= %(end)s and to_date >= %(start)s <= to_date and docstatus < 2 and status!="Rejected" """ if match_conditions: query += " and " + match_conditions - for d in frappe.db.sql(query, (start, end, start, end), as_dict=True): + for d in frappe.db.sql(query, {"start":start, "end": end}, as_dict=True): e = { "name": d.name, "doctype": "Leave Application", diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 3934935206..7d0405b1dd 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -523,9 +523,9 @@ def get_events(start, end, filters=None): planned_end_date, status from `tabProduction Order` where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \ - and (planned_start_date between %(start)s and %(end)s) \ - or ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \ - and planned_end_date between %(start)s and %(end)s)) {conditions} + and (planned_start_date <= %(end)s) \ + and ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \ + and planned_end_date >= %(start)s)) {conditions} """.format(conditions=conditions), { "start": start, "end": end diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index a9b48fc070..0ae2f8b945 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -133,9 +133,9 @@ def get_events(start, end, filters=None): data = frappe.db.sql("""select name, exp_start_date, exp_end_date, subject, status, project from `tabTask` where ((ifnull(exp_start_date, '0000-00-00')!= '0000-00-00') \ - and (exp_start_date between %(start)s and %(end)s) \ - or ((ifnull(exp_start_date, '0000-00-00')!= '0000-00-00') \ - and exp_end_date between %(start)s and %(end)s)) + and (exp_start_date <= %(end)s) \ + or ((ifnull(exp_end_date, '0000-00-00')!= '0000-00-00') \ + and exp_end_date >= %(start)s)) {conditions}""".format(conditions=conditions), { "start": start, "end": end diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 02e5f18f84..6e26212332 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -362,7 +362,7 @@ def get_events(start, end, filters=None): from `tabTimesheet Detail`, `tabTimesheet` where `tabTimesheet Detail`.parent = `tabTimesheet`.name and `tabTimesheet`.docstatus < 2 - and (from_time between %(start)s and %(end)s) {conditions} {match_cond} + and (from_time <= %(end)s and to_time >= %(start)s) {conditions} {match_cond} """.format(conditions=conditions, match_cond = get_match_cond('Timesheet')), { "start": start, diff --git a/erpnext/projects/doctype/timesheet/timesheet_calendar.js b/erpnext/projects/doctype/timesheet/timesheet_calendar.js index ad81de65cd..b22cd09f7f 100644 --- a/erpnext/projects/doctype/timesheet/timesheet_calendar.js +++ b/erpnext/projects/doctype/timesheet/timesheet_calendar.js @@ -29,4 +29,4 @@ frappe.views.calendar["Timesheet"] = { } ], get_events_method: "erpnext.projects.doctype.timesheet.timesheet.get_events" -} \ No newline at end of file +}