Files
enlight-lms/lms/patches/v1_0/create_class_student_registration.py
2023-08-18 17:38:20 +05:30

24 lines
767 B
Python

import frappe
def execute():
frappe.reload_doc("lms", "doctype", "class_student")
frappe.reload_doc("lms", "doctype", "class_student_registration")
students = frappe.get_all(
"Class Student", {"parent": ["is", "set"]}, ["name", "student", "parent"]
)
for student in students:
student_details = frappe.db.get_value(
"User", student.student, ["full_name", "username"], as_dict=1
)
registration = frappe.new_doc("Class Student Registration")
registration.member = student.student
registration.member_name = student_details.full_name
registration.member_username = student_details.username
registration.class_name = student.parent
registration.save()
frappe.db.set_value("Class Student", student.name, "class_student", registration.name)