From a8454e27645cfe216ab73ea1446e335cf7f38e93 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 23 Jan 2013 16:01:35 +0530 Subject: [PATCH] removed unwanted permission --- patches/january_2013/remove_unwanted_permission.py | 14 ++++++++++++++ patches/patch_list.py | 1 + 2 files changed, 15 insertions(+) create mode 100644 patches/january_2013/remove_unwanted_permission.py diff --git a/patches/january_2013/remove_unwanted_permission.py b/patches/january_2013/remove_unwanted_permission.py new file mode 100644 index 00000000000..2c014ec57f7 --- /dev/null +++ b/patches/january_2013/remove_unwanted_permission.py @@ -0,0 +1,14 @@ +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.model_wrapper("DocType", dt[0]) + 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` + where parent = %s and permlevel = %s""", (dt[0], pl)) + print doctype.doc.name \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index cdaa2ad9a19..7e87fe41e0b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -155,4 +155,5 @@ patch_list = [ "patches.january_2013.purchase_price_list", "execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')", "patches.january_2013.update_fraction_for_usd", + "patches.january_2013.remove_unwanted_permission", ] \ No newline at end of file