Bug? Permission does not update/add to the production server

Permission rule update/add in your development box is not updated to production server.

Step to replicate

In your development box

  1. Go to setup/customize/doctype. Select any custom or erpnext doctype
  2. Add a new row in Permission Rule and fill out the fields.
  3. git commit and push your code.

In your production box

  1. bench update
  2. 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.

Any thoughts?

@ccfiel, do you need add these custom persmissions as fixtures!

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.

@max_morais_dmm how? What shall I add in my hooks.py? This is my fixtures now

fixtures = ["Custom Field", "Property Setter"]


Thanks for the reply. I have look at commands.py

def reset_perms(context):
	"Reset permissions for all doctypes"
	from frappe.permissions import reset_perms
	print context.sites
	for site in context.sites:
			for d in frappe.db.sql_list("""select name from `tabDocType`
				where istable=0 and custom=0"""):

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?

Have you tried bench --site <your_site_name> reset-perms ?

@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.

Try bench --site all reset-perms

@nabinhait thanks its getting all the sites :smile:

1 Like