From 9936100a6a681517b999a2b4763f81eb33f9d11a Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 16 Jun 2017 22:18:20 +0530 Subject: [PATCH] send email on update and on update after submit fixes #8898 --- .../doctype/training_event/training_event.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/erpnext/hr/doctype/training_event/training_event.py b/erpnext/hr/doctype/training_event/training_event.py index c9be3dd914..27ae8cf549 100644 --- a/erpnext/hr/doctype/training_event/training_event.py +++ b/erpnext/hr/doctype/training_event/training_event.py @@ -8,20 +8,19 @@ from frappe import _ from frappe.model.document import Document class TrainingEvent(Document): - def validate(self): - if self.event_status == "Scheduled": - self.invite_employee() + def on_update(self): + self.invite_employee() def on_update_after_submit(self): - if self.event_status == "Scheduled" and self.send_email: - self.invite_employee() + self.invite_employee() def invite_employee(self): - subject = _("""You are invited for to attend {0} - {1} scheduled from {2} to {3} at {4}."""\ - .format(self.type, self.event_name, self.start_time, self.end_time, self.location)) - - for emp in self.employees: - if emp.status== "Open": - frappe.sendmail(frappe.db.get_value("Employee", emp.employee, "company_email"), \ - subject=subject, content= self.introduction) - emp.status= "Invited" \ No newline at end of file + if self.event_status == "Scheduled" and self.send_email: + subject = _("""You are invited for to attend {0} - {1} scheduled from {2} to {3} at {4}."""\ + .format(self.type, self.event_name, self.start_time, self.end_time, self.location)) + + for emp in self.employees: + if emp.status== "Open": + frappe.sendmail(frappe.db.get_value("Employee", emp.employee, "company_email"), \ + subject=subject, content= self.introduction) + emp.status= "Invited" \ No newline at end of file