Add Calendar in Training Event Doctype (#11090)
This commit is contained in:
parent
7eaeec951d
commit
5cb6c38a34
@ -3,6 +3,7 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from erpnext.hr.doctype.employee.employee import get_employee_emails
|
from erpnext.hr.doctype.employee.employee import get_employee_emails
|
||||||
|
|
||||||
@ -10,3 +11,29 @@ class TrainingEvent(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.employee_emails = ', '.join(get_employee_emails([d.employee
|
self.employee_emails = ', '.join(get_employee_emails([d.employee
|
||||||
for d in self.employees]))
|
for d in self.employees]))
|
||||||
|
|
||||||
|
@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("Training Event", filters)
|
||||||
|
|
||||||
|
data = frappe.db.sql("""
|
||||||
|
select
|
||||||
|
name, event_name, event_status, start_time, end_time
|
||||||
|
from
|
||||||
|
`tabTraining Event`
|
||||||
|
where (ifnull(start_time, '0000-00-00')!= '0000-00-00') \
|
||||||
|
and (start_time between %(start)s and %(end)s)
|
||||||
|
and docstatus < 2
|
||||||
|
{conditions}
|
||||||
|
""".format(conditions=conditions), {
|
||||||
|
"start": start,
|
||||||
|
"end": end
|
||||||
|
}, as_dict=True, update={"allDay": 0})
|
||||||
|
return data
|
||||||
|
14
erpnext/hr/doctype/training_event/training_event_calendar.js
Normal file
14
erpnext/hr/doctype/training_event/training_event_calendar.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
frappe.views.calendar["Training Event"] = {
|
||||||
|
field_map: {
|
||||||
|
"start": "start_time",
|
||||||
|
"end": "end_time",
|
||||||
|
"id": "name",
|
||||||
|
"title": "event_name",
|
||||||
|
"allDay": "allDay"
|
||||||
|
},
|
||||||
|
gantt: true,
|
||||||
|
get_events_method: "erpnext.hr.doctype.training_event.training_event.get_events",
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user