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:
parent
9046c13858
commit
5380a4c3db
@ -5,12 +5,14 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.utils import getdate,today
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.desk.form.linked_with import get_linked_doctypes
|
from frappe.desk.form.linked_with import get_linked_doctypes
|
||||||
from erpnext.education.utils import check_content_completion, check_quiz_completion
|
from erpnext.education.utils import check_content_completion, check_quiz_completion
|
||||||
class Student(Document):
|
class Student(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))
|
self.title = " ".join(filter(None, [self.first_name, self.middle_name, self.last_name]))
|
||||||
|
self.validate_dates()
|
||||||
|
|
||||||
if self.student_applicant:
|
if self.student_applicant:
|
||||||
self.check_unique()
|
self.check_unique()
|
||||||
@ -19,6 +21,10 @@ class Student(Document):
|
|||||||
if frappe.get_value("Student", self.name, "title") != self.title:
|
if frappe.get_value("Student", self.name, "title") != self.title:
|
||||||
self.update_student_name_in_linked_doctype()
|
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):
|
def update_student_name_in_linked_doctype(self):
|
||||||
linked_doctypes = get_linked_doctypes("Student")
|
linked_doctypes = get_linked_doctypes("Student")
|
||||||
for d in linked_doctypes:
|
for d in linked_doctypes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user