Creating custom role when installing custom app

Hi,

How to get a custom role to be automatically created and default permission to certain doctype to be set on this role, when I install a custom app to a site?
Can anyone please give me a hint? Thank you in advance.

-Lucky

@luckyismail,

You can export the roles as fixtures in your custom app. Those roles then can be installed automatically after you install your app in frappe.

Thanks, Makarand

2 Likes

Export the role. Got it!
Thank you @makarand_b

@luckyismail,

you can also filter the roles so that only custom roles will be included in fixtures.

try

fixtures = [{
	"doctype": "Role",
	"filters": {
		"name": ["in", "Role1,Role2"]
	}]
2 Likes