diff --git a/erpnext/education/doctype/student/student.js b/erpnext/education/doctype/student/student.js index b6e741c4da..66df6b977e 100644 --- a/erpnext/education/doctype/student/student.js +++ b/erpnext/education/doctype/student/student.js @@ -31,8 +31,9 @@ frappe.ui.form.on('Student', { frappe.ui.form.on('Student Guardian', { guardians_add: function(frm){ frm.fields_dict['guardians'].grid.get_field('guardian').get_query = function(doc){ - var guardian_list = []; + let guardian_list = []; if(!doc.__islocal) guardian_list.push(doc.guardian); + $.each(doc.guardians, function(idx, val){ if (val.guardian) guardian_list.push(val.guardian); }); @@ -40,3 +41,21 @@ frappe.ui.form.on('Student Guardian', { }; } }); + + +frappe.ui.form.on('Student Sibling', { + siblings_add: function(frm){ + frm.fields_dict['siblings'].grid.get_field('student').get_query = function(doc){ + let sibling_list = [frm.doc.name]; + if(!doc.__islocal) sibling_list.push(doc.student); + + $.each(doc.siblings, function(idx, val){ + if (val.student && val.studying_in_same_institute == 'YES') { + sibling_list.push(val.student); + } + + }); + return { filters: [['Student', 'name', 'not in', sibling_list]] }; + }; + } +}); \ No newline at end of file