Hello there,
I am trying to filter the default calendar by code.
I already created in hooks.py:
doctype_list_js = {
"Event": "public/js/event_list.js"
}
In event_list.js is the following code:
frappe.listview_settings['Event'] = {
add_fields: ["event_type", "starts_on", "ends_on"],
filters: [["event_type", "!=", "Cancel"]]
}
I had alert(“Test”); on the last line to see if the file is included, and it was working, so I can be sure, that the file is loaded, when I open the calendar view.
The filter is not set.
The reason I am using the file event_list.js instead of event_calendar.js is because I tried several things in event_calendar.js (and included it in hooks as well), which didn’t work.
Then I saw, that the Leave Application calendar is having a filter which filters out all Rejected Leave Applications. This is done by the following code:
frappe.listview_settings['Leave Application'] = {
add_fields: ["status", "leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"],
filters:[["status","!=", "Rejected"]],
get_indicator: function(doc) {
return [__(doc.status), frappe.utils.guess_colour(doc.status),
"status,=," + doc.status];
}
};
which is located in the file: ~/frappe-bench/apps/erpnext/erpnext/hr/doctype/leave_application/leave_application_list.js
leave_application_calendar.js does not create any filters, so I assume, what I have done so far is in the correct file.
Does anyone know something about this?
Thank you very much.