From e7d52c594b4390f7b9dc9c0de2c0e315db3a68f0 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Wed, 12 Dec 2018 16:13:58 +0530 Subject: [PATCH] [Major][Breaking] Program Enrollment Creates Course enrollment --- .../doctype/program_enrollment/program_enrollment.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.py b/erpnext/education/doctype/program_enrollment/program_enrollment.py index 320a58a924..c4f634fa19 100644 --- a/erpnext/education/doctype/program_enrollment/program_enrollment.py +++ b/erpnext/education/doctype/program_enrollment/program_enrollment.py @@ -20,6 +20,7 @@ class ProgramEnrollment(Document): def on_submit(self): self.update_student_joining_date() self.make_fee_records() + self.create_course_enrollments() def validate_duplication(self): enrollment = frappe.get_all("Program Enrollment", filters={ @@ -66,7 +67,13 @@ class ProgramEnrollment(Document): def get_courses(self): return frappe.db.sql('''select course, course_name from `tabProgram Course` where parent = %s and required = 1''', (self.program), as_dict=1) - + def create_course_enrollments(self): + student = frappe.get_doc("Student", self.student) + program = frappe.get_doc("Program", self.program) + course_list = [course.course for course in program.get_all_children()] + for course_name in course_list: + student.enroll_in_course(course_name=course_name, program_enrollment=self.name) + @frappe.whitelist() def get_program_courses(doctype, txt, searchfield, start, page_len, filters): if filters.get('program'):