[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:
parent
8a052cb153
commit
5e470f757f
@ -44,26 +44,3 @@ class AssetMaintenanceLog(Document):
|
||||
def get_maintenance_tasks(doctype, txt, searchfield, start, page_len, filters):
|
||||
asset_maintenance_tasks = frappe.db.get_values('Asset Maintenance Task', {'parent':filters.get("asset_maintenance")}, 'maintenance_task')
|
||||
return asset_maintenance_tasks
|
||||
|
||||
@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("Asset Maintenance Log", filters)
|
||||
data = frappe.db.sql("""select name, due_date, due_date,
|
||||
task, maintenance_status, asset_name from `tabAsset Maintenance Log`
|
||||
where ((ifnull(due_date, '0000-00-00')!= '0000-00-00') \
|
||||
and (due_date <= %(end)s) \
|
||||
or ((ifnull(due_date, '0000-00-00')!= '0000-00-00') \
|
||||
and due_date >= %(start)s))
|
||||
{conditions}""".format(conditions=conditions), {
|
||||
"start": start,
|
||||
"end": end
|
||||
}, as_dict=True, update={"allDay": 0})
|
||||
|
||||
return data
|
@ -18,5 +18,5 @@ frappe.views.calendar["Asset Maintenance Log"] = {
|
||||
"label": __("Asset Maintenance")
|
||||
}
|
||||
],
|
||||
get_events_method: "erpnext.assets.doctype.asset_maintenance_log.asset_maintenance_log.get_events"
|
||||
get_events_method: "frappe.desk.calendar.get_events"
|
||||
};
|
||||
|
@ -11,29 +11,3 @@ class TrainingEvent(Document):
|
||||
def validate(self):
|
||||
self.employee_emails = ', '.join(get_employee_emails([d.employee
|
||||
for d in self.employees]))
|
||||
|
||||
@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("Training Event", filters)
|
||||
|
||||
data = frappe.db.sql("""
|
||||
select
|
||||
name, event_name, event_status, start_time, end_time
|
||||
from
|
||||
`tabTraining Event`
|
||||
where (ifnull(start_time, '0000-00-00')!= '0000-00-00') \
|
||||
and (start_time between %(start)s and %(end)s)
|
||||
and docstatus < 2
|
||||
{conditions}
|
||||
""".format(conditions=conditions), {
|
||||
"start": start,
|
||||
"end": end
|
||||
}, as_dict=True, update={"allDay": 0})
|
||||
return data
|
||||
|
@ -10,5 +10,5 @@ frappe.views.calendar["Training Event"] = {
|
||||
"allDay": "allDay"
|
||||
},
|
||||
gantt: true,
|
||||
get_events_method: "erpnext.hr.doctype.training_event.training_event.get_events",
|
||||
get_events_method: "frappe.desk.calendar.get_events",
|
||||
}
|
||||
|
@ -561,30 +561,6 @@ def make_stock_entry(production_order_id, purpose, qty=None):
|
||||
stock_entry.get_items()
|
||||
return stock_entry.as_dict()
|
||||
|
||||
@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("Production Order", filters)
|
||||
|
||||
data = frappe.db.sql("""select name, production_item, planned_start_date,
|
||||
planned_end_date, status
|
||||
from `tabProduction Order`
|
||||
where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
||||
and (planned_start_date <= %(end)s) \
|
||||
and ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
||||
and ifnull(planned_end_date, '2199-12-31 00:00:00') >= %(start)s)) {conditions}
|
||||
""".format(conditions=conditions), {
|
||||
"start": start,
|
||||
"end": end
|
||||
}, as_dict=True, update={"allDay": 0})
|
||||
return data
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_timesheet(production_order, company):
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
|
@ -42,5 +42,5 @@ frappe.views.calendar["Production Order"] = {
|
||||
"label": __("WIP Warehouse")
|
||||
}
|
||||
],
|
||||
get_events_method: "erpnext.manufacturing.doctype.production_order.production_order.get_events"
|
||||
get_events_method: "frappe.desk.calendar.get_events"
|
||||
}
|
||||
|
@ -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`
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Restaurant Reservation', {
|
||||
setup: function(frm) {
|
||||
frm.add_fetch('customer', 'customer_name', 'customer_name');
|
||||
},
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
|
@ -12,30 +12,3 @@ class RestaurantReservation(Document):
|
||||
def validate(self):
|
||||
if not self.reservation_end_time:
|
||||
self.reservation_end_time = get_datetime(self.reservation_time) + timedelta(hours=1)
|
||||
|
||||
@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("Restaurant Reservation", filters)
|
||||
|
||||
data = frappe.db.sql("""select name, reservation_time,
|
||||
reservation_end_time, customer_name, status, no_of_people
|
||||
from
|
||||
`tabRestaurant Reservation`
|
||||
where
|
||||
((ifnull(reservation_time, '0000-00-00')!= '0000-00-00') \
|
||||
and (reservation_time <= %(end)s) \
|
||||
or ((ifnull(reservation_end_time, '0000-00-00')!= '0000-00-00') \
|
||||
and reservation_end_time >= %(start)s))
|
||||
{conditions}""".format(conditions=conditions), {
|
||||
"start": start,
|
||||
"end": end
|
||||
}, as_dict=True, update={"allDay": 0})
|
||||
|
||||
return data
|
||||
|
@ -14,5 +14,5 @@ frappe.views.calendar["Restaurant Reservation"] = {
|
||||
"label": __("Customer Name")
|
||||
}
|
||||
],
|
||||
get_events_method: "erpnext.restaurant.doctype.restaurant_reservation.restaurant_reservation.get_events"
|
||||
get_events_method: "frappe.desk.calendar.get_events"
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user