Adding a calendar view on custom module/doctype

Greetings,

Ive created an app called Shows with a doctype called Show then i want to add a calendar view to my show doctype my js (show_calendar.js) looks like this

frappe.views.calendar["Show"] = {
        field_map: {
                "start": "start",
                "end": "end",
                "id": "name",
                "title": "title",
                "status": "status",
                "allDay": "all_day",
        },
        get_events_method: "shows.shows.doctype.show.show.get_shows",
}

and my py (show.py) looks like this

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document

class Show(Document):
        pass

@frappe.whitelist()
def get_shows(start, end):
        if not frappe.has_permission("Shows", "read"):
                raise frappe.PermissionError

        return frappe.db.sql("""select
                timestamp(`date`, from_time) as start,
                timestamp(`date`, to_time) as end,
                name,
                title,
                status,
                0 as all_day
        from `tabShow`
        where `date` between %(start)s and %(end)s""", {
                "start": start,
                "end": end
        }, as_dict=True)

The actual issue is i cant see anything on the calendar and on the gantt view i see shows but occupying 2-3 days where it was only some hours.
CALENDAR


GANTT

Note: both are stored in frappe-bench/apps/shows/shows/shows/doctype/show$

Thanks,
Oasis

1 Like

I think you need to create a separate file show_calendar.js for the purpose. Check following link for an example:

I think the start and end date fields must have some valid value to show on calendar, (that’s why they are shown as dotted on gantt view)

hey i also wrote the same code but i have nothing at calendar window not even its title changed.

Im very new to frappe please tell how did you able view this