Fixes in the patch (#9027)
* fix in the patch * new patch for student groups * changes in the merge student batch patch
This commit is contained in:
parent
cf92be88b7
commit
f02c82aeca
@ -8,9 +8,9 @@ from frappe.model.mapper import get_mapped_doc
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
|
||||||
# for converting student batch into student group
|
# for converting student batch into student group
|
||||||
frappe.reload_doctype("Student Group")
|
for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance"]:
|
||||||
|
frappe.reload_doc("schools", "doctype", doctype)
|
||||||
|
|
||||||
if frappe.db.table_exists("Student Batch"):
|
if frappe.db.table_exists("Student Batch"):
|
||||||
student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
|
student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
|
||||||
@ -32,7 +32,7 @@ def execute():
|
|||||||
else:
|
else:
|
||||||
cond = " "
|
cond = " "
|
||||||
student_list = frappe.db.sql('''select student, student_name {cond} from `tabStudent Batch Student`
|
student_list = frappe.db.sql('''select student, student_name {cond} from `tabStudent Batch Student`
|
||||||
where parent=%s'''.format(cond=cond), (doc.name), as_dict=1)
|
where parent=%s'''.format(cond=cond), (doc.student_group_name), as_dict=1)
|
||||||
|
|
||||||
if student_list:
|
if student_list:
|
||||||
for i, student in enumerate(student_list):
|
for i, student in enumerate(student_list):
|
||||||
@ -40,7 +40,7 @@ def execute():
|
|||||||
doc.extend("students", student_list)
|
doc.extend("students", student_list)
|
||||||
|
|
||||||
instructor_list = frappe.db.sql('''select instructor, instructor_name from `tabStudent Batch Instructor`
|
instructor_list = frappe.db.sql('''select instructor, instructor_name from `tabStudent Batch Instructor`
|
||||||
where parent=%s''', (doc.name), as_dict=1)
|
where parent=%s''', (doc.student_group_name), as_dict=1)
|
||||||
if instructor_list:
|
if instructor_list:
|
||||||
doc.extend("instructors", instructor_list)
|
doc.extend("instructors", instructor_list)
|
||||||
doc.save()
|
doc.save()
|
||||||
@ -62,8 +62,6 @@ def execute():
|
|||||||
frappe.delete_doc("DocType", "Attendance Tool Student", force=1)
|
frappe.delete_doc("DocType", "Attendance Tool Student", force=1)
|
||||||
|
|
||||||
# change the student batch to student group in the student attendance
|
# change the student batch to student group in the student attendance
|
||||||
frappe.reload_doctype("Student Attendance")
|
|
||||||
|
|
||||||
table_columns = frappe.db.get_table_columns("Student Attendance")
|
table_columns = frappe.db.get_table_columns("Student Attendance")
|
||||||
if "student_batch" in table_columns:
|
if "student_batch" in table_columns:
|
||||||
rename_field("Student Attendance", "student_batch", "student_group")
|
rename_field("Student Attendance", "student_batch", "student_group")
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
# Copyright (c) 2017, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.model.utils.rename_field import *
|
||||||
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if frappe.db.table_exists("Student Batch"):
|
||||||
|
student_batches = frappe.db.sql('''select name from `tabStudent Batch`''', as_dict=1)
|
||||||
|
|
||||||
|
for student_batch in student_batches:
|
||||||
|
if frappe.db.exists("Student Group", student_batch.get("name")):
|
||||||
|
student_group = frappe.get_doc("Student Group", student_batch.get("name"))
|
||||||
|
|
||||||
|
if frappe.db.table_exists("Student Batch Student"):
|
||||||
|
current_student_list = frappe.db.sql_list('''select student from `tabStudent Group Student`
|
||||||
|
where parent=%s''', (student_group.name))
|
||||||
|
batch_student_list = frappe.db.sql_list('''select student from `tabStudent Batch Student`
|
||||||
|
where parent=%s''', (student_group.name))
|
||||||
|
|
||||||
|
student_list = list(set(batch_student_list)-set(current_student_list))
|
||||||
|
if student_list:
|
||||||
|
student_group.extend("students", [{"student":d} for d in student_list])
|
||||||
|
|
||||||
|
if frappe.db.table_exists("Student Batch Instructor"):
|
||||||
|
current_instructor_list = frappe.db.sql_list('''select instructor from `tabStudent Group Instructor`
|
||||||
|
where parent=%s''', (student_group.name))
|
||||||
|
batch_instructor_list = frappe.db.sql_list('''select instructor from `tabStudent Batch Instructor`
|
||||||
|
where parent=%s''', (student_group.name))
|
||||||
|
|
||||||
|
instructor_list = list(set(batch_instructor_list)-set(current_instructor_list))
|
||||||
|
if instructor_list:
|
||||||
|
student_group.extend("instructors", [{"instructor":d} for d in instructor_list])
|
||||||
|
|
||||||
|
student_group.save()
|
Loading…
x
Reference in New Issue
Block a user