From 0cc837eac5f66be7042a18241de58c1747d50867 Mon Sep 17 00:00:00 2001 From: Pranav Nachanekar Date: Wed, 11 Sep 2019 14:12:30 +0530 Subject: [PATCH] Create event for the appointment TODO: Add lead and employee to this --- erpnext/crm/doctype/appointment/appointment.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py index cce6a1d684..30d10194b2 100644 --- a/erpnext/crm/doctype/appointment/appointment.py +++ b/erpnext/crm/doctype/appointment/appointment.py @@ -3,6 +3,7 @@ # For license information, please see license.txt from __future__ import unicode_literals +from datetime import timedelta import frappe from frappe.model.document import Document @@ -12,4 +13,14 @@ class Appointment(Document): settings = frappe.get_doc('Appointment Booking Settings') if(number_of_appointments_in_same_slot>=settings.number_of_agents): frappe.throw('Time slot is not available') + + def after_insert(self): + appointment_event = frappe.new_doc('Event') + appointment_event.subject = 'Appointment with ' + self.customer_name + appointment_event.starts_on = self.scheduled_time + appointment_event.status = 'Open' + appointment_event.type = 'Private' + settings = frappe.get_doc('Appointment Booking Settings') + appointment_event.ends_on = self.scheduled_time + timedelta(minutes=settings.appointment_duration) + appointment_event.insert()