From 20d82800f3688f0d906009a0922d6b194f2fd83a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 10 Sep 2012 12:03:31 +0530 Subject: [PATCH] add delete permission to communication --- erpnext/patches/patch_list.py | 4 ++++ .../communication_delete_permission.py | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 erpnext/patches/september_2012/communication_delete_permission.py diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 8e0a4a0bbd..e4eff963ef 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -541,4 +541,8 @@ patch_list = [ 'patch_module': 'patches.september_2012', 'patch_file': 'stock_report_permissions_for_accounts', }, + { + 'patch_module': 'patches.september_2012', + 'patch_file': 'communication_delete_permission', + }, ] diff --git a/erpnext/patches/september_2012/communication_delete_permission.py b/erpnext/patches/september_2012/communication_delete_permission.py new file mode 100644 index 0000000000..68aea40e24 --- /dev/null +++ b/erpnext/patches/september_2012/communication_delete_permission.py @@ -0,0 +1,21 @@ +def execute(): + import webnotes + from webnotes.model.doc import addchild + from webnotes.model.code import get_obj + + existing = webnotes.conn.sql("""select role, name from `tabDocPerm` + where permlevel=0 and parent='Communication'""") + + for role in ("Support Manager", "System Manager"): + if role not in map(lambda x: x[0], existing): + doctype_obj = get_obj("DocType", "Communication", with_children=1) + ch = addchild(doctype_obj.doc, "permissions", "DocPerm") + ch.permlevel = 0 + ch.role = role + ch.read = 1 + ch.write = 1 + ch.create = 1 + ch.cancel = 1 + ch.save() + else: + webnotes.conn.set_value("DocPerm", dict(existing).get(role), "cancel", 1)