fix: renamed chapter and lesson doctype

This commit is contained in:
pateljannat
2021-09-29 16:42:07 +05:30
parent 50938afe77
commit dc877a9c09
16 changed files with 270 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import frappe
def execute():
frappe.reload_doc("lms", "doctype", "course_chapter")
frappe.reload_doc("lms", "doctype", "course_lesson")
if not frappe.db.count("Course Chapter"):
move_chapters()
if not frappe.db.count("Course Lesson"):
move_lessons()
frappe.delete_doc("DocType", "Chapter")
frappe.delete_doc("DocType", "Lesson")
def move_chapters():
docs = frappe.get_all("Chapter", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Course Chapter"})
del keys["name"]
frappe.get_doc(keys).save()
def move_lessons():
docs = frappe.get_all("Lesson", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Course Lesson"})
del keys["name"]
frappe.get_doc(keys).save()