Files
enlight-lms/lms/patches/v0_0/multiple_instructors.py
2022-11-04 11:47:09 +05:30

19 lines
452 B
Python

import frappe
def execute():
frappe.reload_doc("lms", "doctype", "lms_course")
frappe.reload_doc("lms", "doctype", "course_instructor")
courses = frappe.get_all("LMS Course", fields=["name", "instructor"])
for course in courses:
doc = frappe.get_doc(
{
"doctype": "Course Instructor",
"parent": course.name,
"parentfield": "instructors",
"parenttype": "LMS Course",
"instructor": course.instructor,
}
)
doc.save()