brotherton-erpnext/erpnext/education/__init__.py

18 lines
476 B
Python
Raw Normal View History

import frappe
from frappe import _
2022-03-28 13:22:46 +00:00
class StudentNotInGroupError(frappe.ValidationError):
pass
def validate_student_belongs_to_group(student, student_group):
2022-03-28 13:22:46 +00:00
groups = frappe.db.get_all("Student Group Student", ["parent"], dict(student=student, active=1))
if not student_group in [d.parent for d in groups]:
2022-03-28 13:22:46 +00:00
frappe.throw(
_("Student {0} does not belong to group {1}").format(
frappe.bold(student), frappe.bold(student_group)
),
StudentNotInGroupError,
)