Added validation to check if Studnet in a student group exists in the student batch specified
This commit is contained in:
parent
50862039dc
commit
05dec9a880
@ -7,6 +7,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from erpnext.schools.utils import validate_duplicate_student
|
||||
from erpnext.schools.api import get_student_batch_students
|
||||
|
||||
class StudentGroup(Document):
|
||||
def autoname(self):
|
||||
@ -29,6 +30,8 @@ class StudentGroup(Document):
|
||||
def validate(self):
|
||||
self.validate_strength()
|
||||
self.validate_student_name()
|
||||
if self.student_batch:
|
||||
self.validate_student_batch()
|
||||
validate_duplicate_student(self.students)
|
||||
|
||||
def validate_strength(self):
|
||||
@ -39,4 +42,10 @@ class StudentGroup(Document):
|
||||
for d in self.students:
|
||||
d.student_name = frappe.db.get_value("Student", d.student, "title")
|
||||
|
||||
|
||||
def validate_student_batch(self):
|
||||
student_batch_students = []
|
||||
for d in get_student_batch_students(self.student_batch):
|
||||
student_batch_students.append(d.student)
|
||||
for d in self.students:
|
||||
if d.student not in student_batch_students:
|
||||
frappe.throw(_("""Student {0}: {1} does not belong to Student Batch {2}""".format(d.student, d.student_name, self.student_batch)))
|
Loading…
x
Reference in New Issue
Block a user