brotherton-erpnext/patches/january_2013/remove_unwanted_permission.py

13 lines
529 B
Python
Raw Normal View History

2013-01-23 10:31:35 +00:00
def execute():
import webnotes
for dt in webnotes.conn.sql("""select name, issingle from tabDocType"""):
if dt[1]:
webnotes.conn.sql("""update tabDocPerm set report = 0 where parent = %s""", dt[0])
doctype = webnotes.bean("DocType", dt[0])
2013-01-23 10:31:35 +00:00
for pl in [1, 2, 3]:
if not doctype.doclist.get({"doctype": "DocField", "permlevel": pl}):
if doctype.doclist.get({"doctype":"DocPerm", "permlevel":pl}):
webnotes.conn.sql("""delete from `tabDocPerm`
2013-01-23 10:40:15 +00:00
where parent = %s and permlevel = %s""", (dt[0], pl))