brotherton-erpnext/erpnext/patches/v7_0/make_guardian.py
Manas Solanki 966f141f62 Rename schools to Education ()
* renaming for the docs, demo data and patch

* changes in the doctypes and reports

* rename the config file

* Few name changes in messages and license

* rename the school settings to education settings

* changes in the documentation

* added the setup file for the fixtures

* corrected the ui tests file path

* fix the codacy

* add the patch for renaming few doctypes and fields

* changes in the patch
2017-11-23 15:22:10 +05:30

38 lines
1.2 KiB
Python

from __future__ import unicode_literals
import frappe
def execute():
if frappe.db.exists("DocType", "Student"):
student_table_cols = frappe.db.get_table_columns("Student")
if "father_name" in student_table_cols:
# 'Schools' module changed to the 'Education'
# frappe.reload_doc("schools", "doctype", "student")
# frappe.reload_doc("schools", "doctype", "guardian")
# frappe.reload_doc("schools", "doctype", "guardian_interest")
frappe.reload_doc("education", "doctype", "student")
frappe.reload_doc("education", "doctype", "guardian")
frappe.reload_doc("education", "doctype", "guardian_interest")
frappe.reload_doc("hr", "doctype", "interest")
fields = ["name", "father_name", "mother_name"]
if "father_email_id" in student_table_cols:
fields += ["father_email_id", "mother_email_id"]
students = frappe.get_all("Student", fields)
for stud in students:
if stud.father_name:
make_guardian(stud.father_name, stud.name, stud.father_email_id)
if stud.mother_name:
make_guardian(stud.mother_name, stud.name, stud.mother_email_id)
def make_guardian(name, student, email=None):
frappe.get_doc({
'doctype': 'Guardian',
'guardian_name': name,
'email': email,
'student': student
}).insert()