ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

How to save custom user roles to custom app

For an app I would like to create two custom user roles and save them to a custom app where I already have a number of custom doctypes set up. Is it possible to define custom user roles with permissions and save them inside of an app?

Define Custom roles in hooks.py file of your app like this

{"dt": "Role", "filters": [
    [
        "name", "in", [
                "Role1" ,
                "Role2"
		       ]
       ]
]},

and Custom Doc Permission like this

{"dt": "Custom DocPerm", "filters": [
    [
        "role", "in", [
                "Role1",
                "Role2"
		       ]
    ]
]},
2 Likes

Is it correct like this? I do not see the extra user roles show up inside of the user roles list view.
Also, I am just using frappe without erpnext, could that interfere?

image

do it like this

fixtures = [
        {"dt": "Role", "filters": [
            [
            "name", "in", [
                    "Role1" ,
                    "Role2"
    		       ]
                ]
            ]},
        {"dt": "Custom DocPerm", "filters": [
            [   
            "role", "in", [
                    "Role1",
                    "Role2"
    		       ]
                ]
            },
        ]

Hey,

Thanks for your help. I believe it did something but not quite what I needed it. For now I will just develop the roles in our environment and see if I can export them as fixtures later on and try to attach them.

EDIT: You need to check the quote marks to be regular double quotes instead of the angled ones.