From 16d40cf0a3088048bff6f7cb97f0f6d3b6ea2187 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 20 Jan 2017 19:16:39 +0530 Subject: [PATCH] Added ability to disable a student in student group/studnet batch --- erpnext/patches.txt | 3 +- erpnext/patches/v7_2/mark_students_active.py | 7 +++ erpnext/schools/api.py | 6 ++- .../student_attendance_tool.py | 5 +- .../student_batch_student.json | 47 +++++++++++++++++-- .../student_group_student.json | 47 +++++++++++++++++-- 6 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 erpnext/patches/v7_2/mark_students_active.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d683a95f49..bfda4409a0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -364,4 +364,5 @@ erpnext.patches.v7_2.update_assessment_modules erpnext.patches.v7_2.update_doctype_status erpnext.patches.v7_2.update_salary_slips erpnext.patches.v7_2.delete_fleet_management_module_def -erpnext.patches.v7_2.contact_address_links \ No newline at end of file +erpnext.patches.v7_2.contact_address_links +erpnext.patches.v7_2.mark_students_active \ No newline at end of file diff --git a/erpnext/patches/v7_2/mark_students_active.py b/erpnext/patches/v7_2/mark_students_active.py new file mode 100644 index 0000000000..12057edb63 --- /dev/null +++ b/erpnext/patches/v7_2/mark_students_active.py @@ -0,0 +1,7 @@ +import frappe + +def execute(): + frappe.reload_doc('schools', 'doctype', 'student_batch_student') + frappe.reload_doc('schools', 'doctype', 'student_group_student') + frappe.db.sql("update `tabStudent Batch Student` set active=1") + frappe.db.sql("update `tabStudent Group Student` set active=1") diff --git a/erpnext/schools/api.py b/erpnext/schools/api.py index e31a9444ca..81ae9c4af2 100644 --- a/erpnext/schools/api.py +++ b/erpnext/schools/api.py @@ -88,7 +88,8 @@ def get_student_batch_students(student_batch): :param student_batch: Student Batch. """ - students = frappe.get_list("Student Batch Student", fields=["student", "student_name", "idx"] , filters={"parent": student_batch}, order_by= "idx") + students = frappe.get_list("Student Batch Student", fields=["student", "student_name", "idx"] , + filters={"parent": student_batch, "active": 1}, order_by= "idx") return students @frappe.whitelist() @@ -97,7 +98,8 @@ def get_student_group_students(student_group): :param student_group: Student Group. """ - students = frappe.get_list("Student Group Student", fields=["student", "student_name"] , filters={"parent": student_group}, order_by= "idx") + students = frappe.get_list("Student Group Student", fields=["student", "student_name"] , + filters={"parent": student_group, "active": 1}, order_by= "idx") return students @frappe.whitelist() diff --git a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.py b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.py index 30a692cf18..58588a9058 100644 --- a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.py +++ b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.py @@ -18,11 +18,12 @@ def get_student_attendance_records(based_on, date=None, student_batch=None, cour student_group = frappe.db.get_value("Course Schedule", course_schedule, "student_group") if student_group: student_list = frappe.get_list("Student Group Student", fields=["student", "student_name", "idx"] , \ - filters={"parent": student_group}, order_by= "idx") + filters={"parent": student_group, "active": 1}, order_by= "idx") else: student_batch = frappe.db.get_value("Course Schedule", course_schedule, "student_batch") if not student_list: - student_list = frappe.get_list("Student Batch Student", fields=["student", "student_name", "idx"] , filters={"parent": student_batch}, order_by= "idx") + student_list = frappe.get_list("Student Batch Student", fields=["student", "student_name", "idx"] , + filters={"parent": student_batch, "active": 1}, order_by= "idx") if course_schedule: student_attendance_list= frappe.db.sql("""select student, status from `tabStudent Attendance` where \ diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.json b/erpnext/schools/doctype/student_batch_student/student_batch_student.json index c9b1b01cc5..5933f9e838 100644 --- a/erpnext/schools/doctype/student_batch_student/student_batch_student.json +++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.json @@ -14,6 +14,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "student", "fieldtype": "Link", "hidden": 0, @@ -21,6 +22,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Student", "length": 0, "no_copy": 0, @@ -30,6 +32,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -40,13 +43,17 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "column_break_2", - "fieldtype": "Column Break", + "columns": 0, + "default": "1", + "fieldname": "active", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, + "label": "Active", "length": 0, "no_copy": 0, "permlevel": 0, @@ -54,6 +61,7 @@ "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, @@ -64,6 +72,34 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 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_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, "fieldname": "student_name", "fieldtype": "Data", "hidden": 0, @@ -71,6 +107,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Student Name", "length": 0, "no_copy": 0, @@ -80,6 +117,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -97,8 +135,8 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-07-22 03:27:52.913126", - "modified_by": "Administrator", + "modified": "2017-01-20 18:26:51.242924", + "modified_by": "neil@frappe.io", "module": "Schools", "name": "Student Batch Student", "name_case": "", @@ -109,5 +147,6 @@ "read_only_onload": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/schools/doctype/student_group_student/student_group_student.json b/erpnext/schools/doctype/student_group_student/student_group_student.json index 94493aef84..df49ba8368 100644 --- a/erpnext/schools/doctype/student_group_student/student_group_student.json +++ b/erpnext/schools/doctype/student_group_student/student_group_student.json @@ -14,6 +14,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "student", "fieldtype": "Link", "hidden": 0, @@ -21,6 +22,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Student", "length": 0, "no_copy": 0, @@ -30,6 +32,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, "search_index": 0, @@ -40,13 +43,17 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "column_break_2", - "fieldtype": "Column Break", + "columns": 0, + "default": "1", + "fieldname": "active", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, + "in_standard_filter": 0, + "label": "Active", "length": 0, "no_copy": 0, "permlevel": 0, @@ -54,6 +61,7 @@ "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, @@ -64,6 +72,34 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 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_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, "fieldname": "student_name", "fieldtype": "Data", "hidden": 0, @@ -71,6 +107,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Student Name", "length": 0, "no_copy": 0, @@ -79,6 +116,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -96,8 +134,8 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-07-21 12:27:02.479077", - "modified_by": "Administrator", + "modified": "2017-01-20 19:11:16.837202", + "modified_by": "neil@frappe.io", "module": "Schools", "name": "Student Group Student", "name_case": "", @@ -108,5 +146,6 @@ "read_only_onload": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file