fix-education: date of birth validation
This commit is contained in:
parent
c08ce703c9
commit
9f0699f7e3
@ -5,12 +5,14 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import getdate,today
|
||||
from frappe import _
|
||||
from frappe.desk.form.linked_with import get_linked_doctypes
|
||||
from erpnext.education.utils import check_content_completion, check_quiz_completion
|
||||
class Student(Document):
|
||||
def validate(self):
|
||||
self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))
|
||||
self.validate_dates()
|
||||
|
||||
if self.student_applicant:
|
||||
self.check_unique()
|
||||
@ -19,6 +21,10 @@ class Student(Document):
|
||||
if frappe.get_value("Student", self.name, "title") != self.title:
|
||||
self.update_student_name_in_linked_doctype()
|
||||
|
||||
def validate_dates(self):
|
||||
if self.date_of_birth and getdate(self.date_of_birth) >= getdate(today()):
|
||||
frappe.throw(_("Date of Birth cannot be greater than today."))
|
||||
|
||||
def update_student_name_in_linked_doctype(self):
|
||||
linked_doctypes = get_linked_doctypes("Student")
|
||||
for d in linked_doctypes:
|
||||
|
Loading…
Reference in New Issue
Block a user