[Fix] Filter on child table not working in Calendar (#11824)

* use the new get_events method

* using the common get_events method for calendar_view

* using add_fetch to fill customer_name
This commit is contained in:
Zarrar
2017-12-04 11:22:25 +05:30
committed by Nabin Hait
parent 8a052cb153
commit 5e470f757f
11 changed files with 8 additions and 129 deletions

View File

@@ -148,30 +148,6 @@ def check_if_child_exists(name):
return frappe.db.sql("""select name from `tabTask`
where parent_task = %s""", name)
@frappe.whitelist()
def get_events(start, end, filters=None):
"""Returns events for Gantt / Calendar view rendering.
:param start: Start date-time.
:param end: End date-time.
:param filters: Filters (JSON).
"""
from frappe.desk.calendar import get_event_conditions
conditions = get_event_conditions("Task", filters)
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 <= %(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
}, as_dict=True, update={"allDay": 0})
return data
def get_project(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond
return frappe.db.sql(""" select name from `tabProject`

View File

@@ -19,5 +19,5 @@ frappe.views.calendar["Task"] = {
"label": __("Project")
}
],
get_events_method: "erpnext.projects.doctype.task.task.get_events"
get_events_method: "frappe.desk.calendar.get_events"
}