patch fix for instructor

This commit is contained in:
Zlash65 2018-05-14 17:16:27 +05:30
parent d25a264e5b
commit 06fd51bf69

View File

@ -32,6 +32,8 @@ def execute():
for d in doctypes:
update_records(d, comp_dict)
update_instructors(comp_dict)
def update_records(doctype, comp_dict):
when_then = []
for company in comp_dict:
@ -48,4 +50,24 @@ def update_records(doctype, comp_dict):
`tab%s`
set
department = CASE %s END
"""%(doctype, " ".join(when_then)), debug=1)
"""%(doctype, " ".join(when_then)))
def update_instructors(comp_dict):
when_then = []
emp_details = frappe.get_all("Employee", fields=["name", "company"])
for employee in emp_details:
records = comp_dict[employee.company]
for department in records:
when_then.append('''
WHEN employee = "%s" and department = "%s"
THEN "%s"
'''%(employee.name, department, records[department]))
frappe.db.sql("""
update
`tabInstructor`
set
department = CASE %s END
"""%(" ".join(when_then)))