2018-04-20 04:58:52 +00:00
|
|
|
import frappe
|
|
|
|
from frappe import _
|
|
|
|
|
|
|
|
def execute():
|
2018-04-23 07:51:35 +00:00
|
|
|
frappe.reload_doc("hr", "doctype", "department_approver")
|
2018-04-20 04:58:52 +00:00
|
|
|
frappe.reload_doc("hr", "doctype", "employee")
|
|
|
|
frappe.reload_doc("hr", "doctype", "department")
|
|
|
|
|
|
|
|
approvers = frappe.db.sql("""select distinct app.leave_approver, emp.department from
|
|
|
|
`tabEmployee Leave Approver` app, `tabEmployee` emp
|
|
|
|
where app.parenttype = 'Employee'
|
|
|
|
and emp.name = app.parent
|
|
|
|
""", as_dict=True)
|
|
|
|
for record in approvers:
|
|
|
|
if record.department:
|
2018-04-23 09:25:19 +00:00
|
|
|
frappe.db.sql("""update `tabDepartment Approver` set parenttype = '{0}',
|
|
|
|
parent = '{1}' and parentfield = 'leave_approver' where approver = '{2}'"""
|
2018-04-20 04:58:52 +00:00
|
|
|
.format(_('Department'), record.department, record.leave_approver))
|