From 6420e602e0b1c741c6afaa783b9334f70ceeab32 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 21 May 2012 15:11:36 +0530 Subject: [PATCH] make server side custom script readonly for system manager --- .../patches/may_2012/cs_server_readonly.py | 30 +++++++++++++++++++ erpnext/patches/patch_list.py | 5 ++++ 2 files changed, 35 insertions(+) create mode 100644 erpnext/patches/may_2012/cs_server_readonly.py diff --git a/erpnext/patches/may_2012/cs_server_readonly.py b/erpnext/patches/may_2012/cs_server_readonly.py new file mode 100644 index 0000000000..0ad74f5ca8 --- /dev/null +++ b/erpnext/patches/may_2012/cs_server_readonly.py @@ -0,0 +1,30 @@ +def execute(): + """Make server custom script readonly for system manager""" + import webnotes.model.doc + new_perms = [ + { + 'parent': 'Custom Script', + 'parentfield': 'permissions', + 'parenttype': 'DocType', + 'role': 'System Manager', + 'permlevel': 1, + 'read': 1, + }, + { + 'parent': 'Custom Script', + 'parentfield': 'permissions', + 'parenttype': 'DocType', + 'role': 'Administrator', + 'permlevel': 1, + 'read': 1, + 'write': 1 + }, + ] + for perms in new_perms: + doc = webnotes.model.doc.Document('DocPerm') + doc.fields.update(perms) + doc.save() + webnotes.conn.commit() + webnotes.conn.begin() + import webnotes.model.sync + webnotes.model.sync.sync('core', 'custom_script') \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 583ced951a..60db1ecee1 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -372,5 +372,10 @@ patch_list = [ 'patch_file': 'customize_form_cleanup', 'description': 'cleanup customize form records' }, + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'cs_server_readonly', + 'description': 'Make server custom script readonly for system manager' + }, ]