Merge pull request #6784 from RobertSchouten/calendar_fix
[fix] calendar range fixes
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index a51e2b5..c6a92ca 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -408,13 +408,13 @@
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 3934935..7d0405b 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -523,9 +523,9 @@
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 a9b48fc..0ae2f8b 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -133,9 +133,9 @@
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 02e5f18..6e26212 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -362,7 +362,7 @@
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 ad81de6..b22cd09 100644
--- a/erpnext/projects/doctype/timesheet/timesheet_calendar.js
+++ b/erpnext/projects/doctype/timesheet/timesheet_calendar.js
@@ -29,4 +29,4 @@
}
],
get_events_method: "erpnext.projects.doctype.timesheet.timesheet.get_events"
-}
\ No newline at end of file
+}