diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 4f7ce1a2958..8e0a4a0bbdb 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -537,4 +537,8 @@ patch_list = [ 'patch_module': 'patches.august_2012', 'patch_file': 'reload_stock_ledger', }, -] \ No newline at end of file + { + 'patch_module': 'patches.september_2012', + 'patch_file': 'stock_report_permissions_for_accounts', + }, +] diff --git a/erpnext/patches/september_2012/__init__.py b/erpnext/patches/september_2012/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py b/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py new file mode 100644 index 00000000000..26af06b710f --- /dev/null +++ b/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py @@ -0,0 +1,17 @@ +def execute(): + import webnotes + from webnotes.model.doc import addchild + from webnotes.model.code import get_obj + + for parent in ("Stock Ledger Entry", "Bin"): + existing = webnotes.conn.sql("""select role from `tabDocPerm` + where permlevel=0 and parent=%s""", (parent,)) + + if "Accounts Manager" not in map(lambda x: x[0], existing): + doctype_obj = get_obj("DocType", parent, with_children=1) + ch = addchild(doctype_obj.doc, "permissions", "DocPerm") + ch.permlevel = 0 + ch.role = "Accounts Manager" + ch.read = 1 + ch.save() + \ No newline at end of file