brotherton-erpnext/patches/december_2012/expense_leave_reload.py

29 lines
1.0 KiB
Python
Raw Normal View History

2013-11-20 07:29:58 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2012-12-05 10:15:48 +00:00
import webnotes
def execute():
2012-12-05 10:21:17 +00:00
# new roles
roles = [r[0] for r in webnotes.conn.sql("""select name from tabRole""")]
2012-12-05 10:21:17 +00:00
if not "Leave Approver" in roles:
webnotes.bean([{"doctype":"Role", "role_name":"Leave Approver",
2012-12-05 10:21:17 +00:00
"__islocal":1, "module":"HR"}]).save()
if not "Expense Approver" in roles:
webnotes.bean([{"doctype":"Role", "role_name":"Expense Approver",
2012-12-05 10:21:17 +00:00
"__islocal":1, "module":"HR"}]).save()
# reload
2012-12-05 10:15:48 +00:00
webnotes.clear_perms("Leave Application")
webnotes.reload_doc("hr", "doctype", "leave_application")
webnotes.clear_perms("Expense Claim")
webnotes.reload_doc("hr", "doctype", "expense_claim")
2012-12-05 10:21:17 +00:00
# remove extra space in Approved Expense Vouchers
2012-12-05 10:15:48 +00:00
webnotes.conn.sql("""update `tabExpense Claim` set approval_status='Approved'
where approval_status='Approved '""")
webnotes.conn.commit()
for t in ['__CacheItem', '__SessionCache', 'tabSupport Ticket Response']:
webnotes.conn.sql("drop table if exists `%s`" % t)