Merge pull request #17569 from Mangesh-Khairnar/training-event-fix
feat: validate training event period
This commit is contained in:
commit
1ab0b78ece
@ -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'))
|
Loading…
Reference in New Issue
Block a user