diff --git a/erpnext/education/doctype/course_enrollment/course_enrollment.py b/erpnext/education/doctype/course_enrollment/course_enrollment.py index a70d40d0890..d52182871dd 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