patch fix for instructor
This commit is contained in:
parent
d25a264e5b
commit
06fd51bf69
@ -32,6 +32,8 @@ def execute():
|
|||||||
for d in doctypes:
|
for d in doctypes:
|
||||||
update_records(d, comp_dict)
|
update_records(d, comp_dict)
|
||||||
|
|
||||||
|
update_instructors(comp_dict)
|
||||||
|
|
||||||
def update_records(doctype, comp_dict):
|
def update_records(doctype, comp_dict):
|
||||||
when_then = []
|
when_then = []
|
||||||
for company in comp_dict:
|
for company in comp_dict:
|
||||||
@ -48,4 +50,24 @@ def update_records(doctype, comp_dict):
|
|||||||
`tab%s`
|
`tab%s`
|
||||||
set
|
set
|
||||||
department = CASE %s END
|
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)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user