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 9e32b528be..8b08df8f4c 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -369,11 +369,11 @@ def get_events(start, end, filters=None): conditions = get_conditions(filters) return frappe.db.sql("""select `tabTimesheet Detail`.name as name, `tabTimesheet Detail`.docstatus as status, `tabTimesheet Detail`.parent as parent, - from_time as start_date, hours, activity_type, project, to_time as end_date + from_time, hours, activity_type, project, to_time 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..47333512cb 100644 --- a/erpnext/projects/doctype/timesheet/timesheet_calendar.js +++ b/erpnext/projects/doctype/timesheet/timesheet_calendar.js @@ -1,7 +1,7 @@ frappe.views.calendar["Timesheet"] = { field_map: { - "start": "start_date", - "end": "end_date", + "start": "from_time", + "end": "to_time", "name": "parent", "id": "name", "title": "name",