Hi,
Can any one help me please
i want to show some data on calendar view based on values in my doctype
for example i have doctype workshop it has a star date and enddate
i want to show this workshop entries in calender like events in erpnext.
please help me please
You need to add workshop_calendar.js in your workshop doctype folder. Please refer this erpnext/task_calendar.js at master · frappe/erpnext · GitHub (in this get_events_method write your query in workshop.py file to get data)
Chaitrali Waghchaure
New Indictrans Technologies
2 Likes
@chaitrali i have tried above method sorry to say that it did’t solve my problem
this is what
created a js file workshop_calender.js
in erpnext/schools/doctype/workshop directory
and then i tried to add some item in workshop
i did’t get any result in calender view
field_map: {
"start": "start_date",
"end": "end_date",
"id": "name",
"instructor_name": "instructor_name"
},
gantt: true,
get_events_method: "erpnext.schools.doctype.workshop.workshop.get_events"```
above is content of worksop_calender.js
schema of workshop
```+------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| name | varchar(140) | NO | PRI | NULL | |
| creation | datetime(6) | YES | | NULL | |
| modified | datetime(6) | YES | | NULL | |
| modified_by | varchar(140) | YES | | NULL | |
| owner | varchar(140) | YES | | NULL | |
| docstatus | int(1) | NO | | 0 | |
| parent | varchar(140) | YES | MUL | NULL | |
| parentfield | varchar(140) | YES | | NULL | |
| parenttype | varchar(140) | YES | | NULL | |
| idx | int(8) | NO | | 0 | |
| _liked_by | text | YES | | NULL | |
| name_of_workshop | varchar(140) | YES | | NULL | |
| end_date | datetime(6) | YES | | NULL | |
| _comments | text | YES | | NULL | |
| _assign | text | YES | | NULL | |
| instructor_name | varchar(140) | YES | | NULL | |
| _user_tags | text | YES | | NULL | |
| start_date | datetime(6) | YES | | NULL | |
| description | text | YES | | NULL | |
+------------------+--------------+------+-----+---------+-------+
thanks for answering me
Please share your server code of get_events, it should be like below:
Get Events
It’s whitelist function, you can also call that method directly from your js file.
@Mukesh_Variyani
my server side code is as follows
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class Workshop(Document):
pass
@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("Workshop", filters)
data = frappe.db.sql("""select name, start_date, end_date,
subject, status, project from `tabWorkshop`
where ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
and (start_date <= %(end)s) \
or ((ifnull(exp_end_date, '0000-00-00')!= '0000-00-00') \
and end_date >= %(start)s))
{conditions}""".format(conditions=conditions), {
"start": start,
"end": end
}, as_dict=True)
return data```
@Mukesh_Variyani
thanks for great support and help your comment helped me to solve the problem