mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
[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:
@@ -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"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user