From 18ddc9294789dc31a8b1415da4044a74cadc1aa0 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Wed, 6 Mar 2019 17:05:17 +0530 Subject: [PATCH] feat: Added check for duplicate course enrollment --- .../doctype/course_enrollment/course_enrollment.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/education/doctype/course_enrollment/course_enrollment.py b/erpnext/education/doctype/course_enrollment/course_enrollment.py index a70d40d089..d52182871d 100644 --- a/erpnext/education/doctype/course_enrollment/course_enrollment.py +++ b/erpnext/education/doctype/course_enrollment/course_enrollment.py @@ -20,4 +20,13 @@ class CourseEnrollment(Document): progress = [] for topic in topics: progress.append(student.get_topic_progress(self.name, topic)) - return reduce(lambda x,y: x+y, progress) # Flatten out the List \ No newline at end of file + return reduce(lambda x,y: x+y, progress) # Flatten out the List + + def validate_duplication(self): + enrollment = frappe.get_all("Course Enrollment", filters={ + "student": self.student, + "course": self.course, + "program_enrollment": self.program_enrollment + }) + if enrollment: + frappe.throw(_("Student is already enrolled.")) \ No newline at end of file