Permission rule update/add in your development box is not updated to production server.
Step to replicate
In your development box
Go to setup/customize/doctype. Select any custom or erpnext doctype
Add a new row in Permission Rule and fill out the fields.
git commit and push your code.
In your production box
bench update
Check if the permission rule applied by going to
a. Go to setup/customize/doctype and permission rule you update/add in the doctype
did not take effect.
Permissions are not reloaded every time on bench update. Currently customized permissions are not saved in a different table, it saves in the default table only. Thats why we can’t reload the permission with the update. If you want to reset perms for all doctypes as per json, there is a command bench reset-perms.
@click.command('reset-perms')
@pass_context
def reset_perms(context):
"Reset permissions for all doctypes"
from frappe.permissions import reset_perms
print context.sites
for site in context.sites:
try:
frappe.init(site=site)
frappe.connect()
for d in frappe.db.sql_list("""select name from `tabDocType`
where istable=0 and custom=0"""):
frappe.clear_cache(doctype=d)
reset_perms(d)
finally:
frappe.destroy()
I have notice every command frappe is referring to context. Is context a config file? because I tried to debug and context.sites only gets 1 site. I have 3 sites created. Any idea where can I set the context values?
@nabinhait yes but only works for 1 site. I thought if I do not put --site context.sites will get all the sites or did I interpreted it wrong? I want to apply the reset-perms to all the sites installed. would it be possible? because in the code its
for site in context.sites:
It was looping so I was thinking it would get 1 to many sites.