add stock report permission for accounts manager

This commit is contained in:
Anand Doshi 2012-09-10 11:23:51 +05:30
parent d7774d0ab0
commit 38ab4ae3ac
3 changed files with 22 additions and 1 deletions

View File

@ -537,4 +537,8 @@ patch_list = [
'patch_module': 'patches.august_2012',
'patch_file': 'reload_stock_ledger',
},
]
{
'patch_module': 'patches.september_2012',
'patch_file': 'stock_report_permissions_for_accounts',
},
]

View File

@ -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()