def execute():
	for doctype in ("Purchase Receipt Item", "Delivery Note Item"):
		frappe.reload_doctype(doctype)

		table_columns = frappe.db.get_table_columns(doctype)
		if "qa_no" in table_columns:
			rename_field(doctype, "qa_no", "quality_inspection")

	frappe.reload_doctype("Item")
	rename_field("Item", "inspection_required", "inspection_required_before_purchase")

	frappe.reload_doc('stock', 'doctype', 'quality_inspection')
	frappe.db.sql("""
		update
			`tabQuality Inspection`
		set
			reference_type = 'Purchase Receipt', reference_name = purchase_receipt_no
		where
			ifnull(purchase_receipt_no, '') != '' and inspection_type = 'Incoming'
	""")

	frappe.db.sql("""
		update
			`tabQuality Inspection`
		set
			reference_type = 'Delivery Note', reference_name = delivery_note_no
		where
			ifnull(delivery_note_no, '') != '' and inspection_type = 'Outgoing'
	""")

	for old_fieldname in ["purchase_receipt_no", "delivery_note_no"]:
		update_reports("Quality Inspection", old_fieldname, "reference_name")
		update_users_report_view_settings("Quality Inspection", old_fieldname, "reference_name")
		update_property_setters("Quality Inspection", old_fieldname, "reference_name")
def execute():

    # for converting student batch into student group
    frappe.reload_doctype("Student Group")
    student_batches = frappe.db.sql(
        '''select name as student_group_name, student_batch_name as batch,
		program, academic_year, academic_term from `tabStudent Batch`''',
        as_dict=1)

    for student_batch in student_batches:
        # create student batch name if does not exists !!
        if student_batch.get("batch") and not frappe.db.exists(
                "Student Batch Name", student_batch.get("batch")):
            frappe.get_doc({
                "doctype": "Student Batch Name",
                "batch_name": student_batch.get("batch")
            }).insert(ignore_permissions=True)

        student_batch.update({
            "doctype": "Student Group",
            "group_based_on": "Batch"
        })
        doc = frappe.get_doc(student_batch)
        student_list = frappe.db.sql(
            '''select student, student_name, active from `tabStudent Batch Student`
			where parent=%s''', (doc.name),
            as_dict=1)
        for i, student in enumerate(student_list):
            student.update({"group_roll_number": i + 1})

        if student_list:
            doc.extend("students", student_list)

        instructor_list = frappe.db.sql(
            '''select instructor, instructor_name from `tabStudent Batch Instructor`
			where parent=%s''', (doc.name),
            as_dict=1)
        if instructor_list:
            doc.extend("instructors", instructor_list)
        doc.save()

    # delete the student batch and child-table
    frappe.delete_doc("DocType", "Student Batch", force=1)
    frappe.delete_doc("DocType", "Student Batch Student", force=1)
    frappe.delete_doc("DocType", "Student Batch Instructor", force=1)

    # delete the student batch creation tool
    frappe.delete_doc("DocType", "Student Batch Creation Tool", force=1)

    # delete the student batch creation tool
    frappe.delete_doc("DocType", "Attendance Tool Student", force=1)

    # 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")
    if "student_batch" in table_columns:
        rename_field("Student Attendance", "student_batch", "student_group")
def execute():
	# for converting student batch into student group
	for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance", "Student"]:
		frappe.reload_doc("schools", "doctype", frappe.scrub(doctype))

	if frappe.db.table_exists("Student Batch"):
		student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
			program, academic_year, academic_term from `tabStudent Batch`''', as_dict=1)

		for student_batch in student_batches:
			# create student batch name if does not exists !!
			if student_batch.get("batch") and not frappe.db.exists("Student Batch Name", student_batch.get("batch")):
				frappe.get_doc({
					"doctype": "Student Batch Name",
					"batch_name": student_batch.get("batch")
				}).insert(ignore_permissions=True)

			student_batch.update({"doctype":"Student Group", "group_based_on": "Batch"})
			doc = frappe.get_doc(student_batch)

			if frappe.db.sql("SHOW COLUMNS FROM `tabStudent Batch Student` LIKE 'active'"):
				cond = ", active"
			else:
				cond = " "
			student_list = frappe.db.sql('''select student, student_name {cond} from `tabStudent Batch Student`
				where parent=%s'''.format(cond=cond), (doc.student_group_name), as_dict=1)

			if student_list:
				for i, student in enumerate(student_list):
					student.update({"group_roll_number": i+1})
				doc.extend("students", student_list)

			instructor_list = frappe.db.sql('''select instructor, instructor_name from `tabStudent Batch Instructor`
				where parent=%s''', (doc.student_group_name), as_dict=1)
			if instructor_list:
				doc.extend("instructors", instructor_list)
			doc.save()

	# delete the student batch and child-table
	if frappe.db.table_exists("Student Batch"):
		frappe.delete_doc("DocType", "Student Batch", force=1)
	if frappe.db.table_exists("Student Batch Student"):
		frappe.delete_doc("DocType", "Student Batch Student", force=1)
	if frappe.db.table_exists("Student Batch Instructor"):
		frappe.delete_doc("DocType", "Student Batch Instructor", force=1)

	# delete the student batch creation tool
	if frappe.db.table_exists("Student Batch Creation Tool"):
		frappe.delete_doc("DocType", "Student Batch Creation Tool", force=1)

	# delete the student batch creation tool
	if frappe.db.table_exists("Attendance Tool Student"):
		frappe.delete_doc("DocType", "Attendance Tool Student", force=1)

	# change the student batch to student group in the student attendance
	table_columns = frappe.db.get_table_columns("Student Attendance")
	if "student_batch" in table_columns:
		rename_field("Student Attendance", "student_batch", "student_group")
示例#4
0
def execute():
    frappe.reload_doc("custom", "doctype", "customize_form")
    frappe.reload_doc("email", "doctype", "email_alert")
    frappe.reload_doc("desk", "doctype", "event")
    frappe.reload_doc("workflow", "doctype", "workflow")

    for dt, field_list in rename_map.items():
        for field in field_list:
            rename_field(dt, field[0], field[1])
示例#5
0
def execute():
    tables = frappe.db.sql_list("show tables")
    if "tabUser" not in tables:
        frappe.rename_doc("DocType", "Profile", "User", force=True)

    frappe.reload_doc("website", "doctype", "blogger")

    if "profile" in get_table_columns("Blogger"):
        rename_field("Blogger", "profile", "user")
示例#6
0
def execute():
    for doctype in ("Purchase Receipt Item", "Delivery Note Item"):
        frappe.reload_doctype(doctype)

        table_columns = frappe.db.get_table_columns(doctype)
        if "qa_no" in table_columns:
            rename_field(doctype, "qa_no", "quality_inspection")

    frappe.reload_doctype("Item")
    rename_field("Item", "inspection_required",
                 "inspection_required_before_purchase")

    frappe.reload_doc('stock', 'doctype', 'quality_inspection')
    frappe.db.sql("""
		update
			`tabQuality Inspection`
		set
			reference_type = 'Purchase Receipt', reference_name = purchase_receipt_no
		where
			ifnull(purchase_receipt_no, '') != '' and inspection_type = 'Incoming'
	""")

    frappe.db.sql("""
		update
			`tabQuality Inspection`
		set
			reference_type = 'Delivery Note', reference_name = delivery_note_no
		where
			ifnull(delivery_note_no, '') != '' and inspection_type = 'Outgoing'
	""")

    for old_fieldname in ["purchase_receipt_no", "delivery_note_no"]:
        update_reports("Quality Inspection", old_fieldname, "reference_name")
        update_users_report_view_settings("Quality Inspection", old_fieldname,
                                          "reference_name")
        update_property_setters("Quality Inspection", old_fieldname,
                                "reference_name")
def execute():
	# for converting student batch into student group
	for doctype in ["Student Group", "Student Group Student", 'Program Enrollment',
		"Student Group Instructor", "Student Attendance", "Student", "Student Batch Name"]:
		frappe.reload_doc("schools", "doctype", frappe.scrub(doctype))

	if frappe.db.table_exists("Student Batch"):
		student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
			program, academic_year, academic_term from `tabStudent Batch`''', as_dict=1)

		for student_batch in student_batches:
			# create student batch name if does not exists !!
			if student_batch.get("batch") and not frappe.db.exists("Student Batch Name", student_batch.get("batch")):
				frappe.get_doc({
					"doctype": "Student Batch Name",
					"batch_name": student_batch.get("batch")
				}).insert(ignore_permissions=True)

			student_batch.update({"doctype":"Student Group", "group_based_on": "Batch"})
			doc = frappe.get_doc(student_batch)

			if frappe.db.sql("SHOW COLUMNS FROM `tabStudent Batch Student` LIKE 'active'"):
				cond = ", active"
			else:
				cond = " "
			student_list = frappe.db.sql('''select student, student_name {cond} from `tabStudent Batch Student`
				where parent=%s'''.format(cond=cond), (doc.student_group_name), as_dict=1)

			if student_list:
				for i, student in enumerate(student_list):
					student.update({"group_roll_number": i+1})
				doc.extend("students", student_list)

			instructor_list = None
			if frappe.db.table_exists("Student Batch Instructor"):
				instructor_list = frappe.db.sql('''select instructor, instructor_name from `tabStudent Batch Instructor`
					where parent=%s''', (doc.student_group_name), as_dict=1)
			if instructor_list:
				doc.extend("instructors", instructor_list)
			doc.save()

	# delete the student batch and child-table
	if frappe.db.table_exists("Student Batch"):
		frappe.delete_doc("DocType", "Student Batch", force=1)
	if frappe.db.table_exists("Student Batch Student"):
		frappe.delete_doc("DocType", "Student Batch Student", force=1)
	if frappe.db.table_exists("Student Batch Instructor"):
		frappe.delete_doc("DocType", "Student Batch Instructor", force=1)

	# delete the student batch creation tool
	if frappe.db.table_exists("Student Batch Creation Tool"):
		frappe.delete_doc("DocType", "Student Batch Creation Tool", force=1)

	# delete the student batch creation tool
	if frappe.db.table_exists("Attendance Tool Student"):
		frappe.delete_doc("DocType", "Attendance Tool Student", force=1)

	# change the student batch to student group in the student attendance
	table_columns = frappe.db.get_table_columns("Student Attendance")
	if "student_batch" in table_columns:
		rename_field("Student Attendance", "student_batch", "student_group")
示例#8
0
def rename_field_if_exists(doctype, old_fieldname, new_fieldname):
    try:
        rename_field(doctype, old_fieldname, new_fieldname)
    except Exception, e:
        if e.args[0] != 1054:
            raise