Filter calendar by code

Hello there,

I am trying to filter the default calendar by code.

I already created in

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.

Any ideas to this?

The get_events server side method should support your filters.

Thank you, I know that it will. But it is not a filter like in Leave Application. Do you know why it is not working?

Check the get_event method in your file…make sure it has event_type as a filter

Thank you chabito79. I know how to do this by filtering in python.

I want to achieve that:

Do you see the “Status != “Rejected””?

This is not working on the normal calendar.

Hey Christoph…You can use set_route to filter the calendar view.

As an example, you can use
frappe.set_route("List", "Patient Appointment", {"physician": "John Doe"})
to filter the Patient Appointment calendar by a physician named John Doe

Nice, I will try. Thank you very much.