Create a new Doctype for using with calendar view

I created a new DocType ( copy and massiv expand from Event ) and named id ProcessStep

What is to do to use it with a Calendar view ??? In the Doctype i set the values for Kanban/Calendar view but it does not show in calendar view…

I found the additional DocType CalendarView and try to Configure a new one with my new DocType ProcessStep but it does not change any thing…

What is to do so i can use a Calendar view with a Custom DocType ???

Hi @Eto,

I think you should check it.
And you can also set in base doctype and custom doctype.

I hope this helps.
Thank You!

1 Like

hmmmm oukey…

for which purpose is this specific line of code?

get_events_method: “frappe.desk.calendar.get_events”

do i need this?

Hi:

Without get_events you can just use doctype fields …

get_events method let you build your own “datasource” for calendar. See this sample on Timesheet doctype.

@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).
	"""
	filters = json.loads(filters)
	from frappe.desk.calendar import get_event_conditions

	conditions = get_event_conditions("Timesheet", filters)

	return frappe.db.sql(
		"""select `tabTimesheet Detail`.name as name,
			`tabTimesheet Detail`.docstatus as status, `tabTimesheet Detail`.parent as parent,
			from_time as start_date, hours, activity_type,
			`tabTimesheet Detail`.project, to_time as end_date,
			CONCAT(`tabTimesheet Detail`.parent, ' (', ROUND(hours,2),' hrs)') as title
		from `tabTimesheet Detail`, `tabTimesheet`
		where `tabTimesheet Detail`.parent = `tabTimesheet`.name
			and `tabTimesheet`.docstatus < 2
			and (from_time <= %(end)s and to_time >= %(start)s) {conditions} {match_cond}
		""".format(
			conditions=conditions, match_cond=get_match_cond("Timesheet")
		),
		{"start": start, "end": end},
		as_dict=True,
		update={"allDay": 0},
	)

This code returns a specific query from child table and data formatted properly, ready to render on calendar.
image

Hope this helps.

2 Likes

nice… thx for advice…

great job!!!