fix-education: date of birth validation on student form (#19875)
* fix: date validation on inpatient record, else condition removing on clinical prcd templ which is not req
* fix:Pricing Rule error AttributeError: 'str' object has no attribute 'get' #19770
* fix:Pricing Rule error AttributeError: 'str' object has no attribute 'get' #19770
* fix: joining and relieving Date can be on same date as valid use case
* fix-education: date of birth validation
diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py
index 76825ce..8e4b4e1 100644
--- a/erpnext/education/doctype/student/student.py
+++ b/erpnext/education/doctype/student/student.py
@@ -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 @@
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: