From b4e8128fdb2f9a2fba64c8616172b1fb1f41b58c Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Sat, 11 May 2019 23:26:47 +0530 Subject: [PATCH] feat: validate training event period --- erpnext/hr/doctype/training_event/training_event.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/hr/doctype/training_event/training_event.py b/erpnext/hr/doctype/training_event/training_event.py index 1b13b70f5b..5064f03308 100644 --- a/erpnext/hr/doctype/training_event/training_event.py +++ b/erpnext/hr/doctype/training_event/training_event.py @@ -5,9 +5,19 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document +from frappe import _ +from frappe.utils import time_diff_in_seconds from erpnext.hr.doctype.employee.employee import get_employee_emails class TrainingEvent(Document): def validate(self): + self.set_employee_emails() + self.validate_period() + + def set_employee_emails(self): self.employee_emails = ', '.join(get_employee_emails([d.employee for d in self.employees])) + + def validate_period(self): + if time_diff_in_seconds(self.end_time, self.start_time) <= 0: + frappe.throw(_('End time cannot be before start time')) \ No newline at end of file