fix: restricted duplicate courses on Program Enrollment doctype (#20611)
diff --git a/erpnext/education/doctype/program_enrollment/program_enrollment.js b/erpnext/education/doctype/program_enrollment/program_enrollment.js
index d35f41a..e3b3e9f 100644
--- a/erpnext/education/doctype/program_enrollment/program_enrollment.js
+++ b/erpnext/education/doctype/program_enrollment/program_enrollment.js
@@ -81,3 +81,16 @@
})
}
});
+
+frappe.ui.form.on('Program Enrollment Course', {
+ courses_add: function(frm){
+ frm.fields_dict['courses'].grid.get_field('course').get_query = function(doc){
+ var course_list = [];
+ if(!doc.__islocal) course_list.push(doc.name);
+ $.each(doc.courses, function(idx, val){
+ if (val.course) course_list.push(val.course);
+ });
+ return { filters: [['Course', 'name', 'not in', course_list]] };
+ };
+ }
+});
\ No newline at end of file