diff --git a/erpnext/schools/doctype/school_settings/school_settings.json b/erpnext/schools/doctype/school_settings/school_settings.json index 5bdb65e1b5..8607a76569 100644 --- a/erpnext/schools/doctype/school_settings/school_settings.json +++ b/erpnext/schools/doctype/school_settings/school_settings.json @@ -13,6 +13,7 @@ "engine": "InnoDB", "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -43,6 +44,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -73,6 +75,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -100,6 +103,66 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_4", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "1", + "fieldname": "validation_from_pe", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Validate the Student Group from Program Enrollment", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -112,7 +175,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-04-05 13:34:57.493516", + "modified": "2017-04-27 15:37:00.159072", "modified_by": "Administrator", "module": "Schools", "name": "School Settings", diff --git a/erpnext/schools/doctype/school_settings/school_settings.py b/erpnext/schools/doctype/school_settings/school_settings.py index 5a1c6fe4a6..6d8efb4279 100644 --- a/erpnext/schools/doctype/school_settings/school_settings.py +++ b/erpnext/schools/doctype/school_settings/school_settings.py @@ -11,6 +11,7 @@ school_keydict = { # "key in defaults": "key in Global Defaults" "academic_year": "current_academic_year", "academic_term": "current_academic_term", + "student_validation_setting": "validation_from_pe", } class SchoolSettings(Document): diff --git a/erpnext/schools/doctype/student_group/student_group.js b/erpnext/schools/doctype/student_group/student_group.js index 2068644ea0..29d8bdbe6d 100644 --- a/erpnext/schools/doctype/student_group/student_group.js +++ b/erpnext/schools/doctype/student_group/student_group.js @@ -1,4 +1,4 @@ -cur_frm.add_fetch("student", "title", "student_name"); + cur_frm.add_fetch("student", "title", "student_name"); frappe.ui.form.on("Student Group", { onload: function(frm) { @@ -43,6 +43,11 @@ frappe.ui.form.on("Student Group", { frm.doc.program = null; frm.doc.batch = null; } + else if (frm.doc.group_based_on == "Activity") { + frm.doc.program =null; + frm.doc.batch =null; + frm.doc.CourseQ =null; + } frm.trigger("set_name"); }, @@ -103,6 +108,7 @@ frappe.ui.form.on("Student Group", { s.group_roll_number = ++max_roll_no; } }); + refresh_field("students"); frm.save(); } else { frappe.msgprint(__("Student Group is already updated.")) diff --git a/erpnext/schools/doctype/student_group/student_group.json b/erpnext/schools/doctype/student_group/student_group.json index 59c5eab053..2caaa7ca1b 100644 --- a/erpnext/schools/doctype/student_group/student_group.json +++ b/erpnext/schools/doctype/student_group/student_group.json @@ -75,6 +75,37 @@ "set_only_once": 1, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval: doc.batch || doc.course || doc.group_based_on == \"Activity\"", + "fieldname": "student_group_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Student Group Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -172,7 +203,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "eval:doc.group_based_on == 'Batch'", + "depends_on": "eval:doc.group_based_on == 'Batch' || doc.group_based_on == 'Course' ", "fieldname": "program", "fieldtype": "Link", "hidden": 0, @@ -204,7 +235,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "eval:doc.group_based_on == 'Batch'", + "depends_on": "eval:doc.group_based_on == 'Batch' || doc.group_based_on == 'Course' ", "fieldname": "batch", "fieldtype": "Link", "hidden": 0, @@ -262,37 +293,6 @@ "set_only_once": 1, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "group_based_on", - "fieldname": "student_group_name", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Student Group Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -459,7 +459,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-04-24 15:53:35.593913", + "modified": "2017-04-25 18:26:27.414487", "modified_by": "Administrator", "module": "Schools", "name": "Student Group", diff --git a/erpnext/schools/doctype/student_group/student_group.py b/erpnext/schools/doctype/student_group/student_group.py index dba8c925a7..afcf970097 100644 --- a/erpnext/schools/doctype/student_group/student_group.py +++ b/erpnext/schools/doctype/student_group/student_group.py @@ -13,7 +13,8 @@ class StudentGroup(Document): def validate(self): self.validate_mandatory_fields() self.validate_strength() - self.validate_students() + if frappe.defaults.get_defaults().student_validation_setting + self.validate_students() validate_duplicate_student(self.students) def validate_mandatory_fields(self): @@ -39,6 +40,7 @@ class StudentGroup(Document): @frappe.whitelist() def get_students(academic_year, group_based_on, program=None, batch=None, course=None): enrolled_students = get_program_enrollment(academic_year, group_based_on, program, batch, course) + print enrolled_students if enrolled_students: student_list = [] @@ -51,18 +53,30 @@ def get_students(academic_year, group_based_on, program=None, batch=None, course return student_list def get_program_enrollment(academic_year, group_based_on, program=None, batch=None, course=None): - if group_based_on == "Batch": - return frappe.db.sql('''select student, student_name from `tabProgram Enrollment` where academic_year = %s - and program = %s and student_batch_name = %s order by student_name asc''',(academic_year, program, batch), as_dict=1) + + condition_course = " and pe.name = pec.parent and pec.course = %(course)s" + condition1_course = ", `tabProgram Enrollment Course` pec" + condition_batch = " and pe.program = %(program)s and pe.student_batch_name = %(batch)s" + + if group_based_on == "Batch": + condition1 = "" + condition2 = condition_batch + elif group_based_on == "Course" and not (program and batch): + condition1 = condition1_course + condition2 = condition_course + elif group_based_on == "Course" and program and batch: + condition1 = condition1_course + condition2 = condition_course + condition_batch + + return frappe.db.sql(''' + select + pe.student, pe.student_name + from + `tabProgram Enrollment` pe {condition1} + where + pe.academic_year = %(academic_year)s {condition2} + order by + pe.student_name asc + '''.format(condition1=condition1, condition2=condition2), + ({"academic_year": academic_year, "program": program, "batch": batch, "course": course}), as_dict=1) - elif group_based_on == "Course": - return frappe.db.sql(''' - select - pe.student, pe.student_name - from - `tabProgram Enrollment` pe, `tabProgram Enrollment Course` pec - where - pe.name = pec.parent and pec.course = %s - order by - pe.student_name asc - ''', (course), as_dict=1) \ No newline at end of file