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
This commit is contained in:
Khushal Trivedi 2019-12-10 21:38:42 +05:30 committed by Nabin Hait
parent 9046c13858
commit 5380a4c3db

View File

@ -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: