Role Control
Advanced role utilities and UI control overrides for Frappe and ERPNext.
- Author: abdullla00
- Repository: https://github.com/abdullla00/role_control
- GitHub stars: 3
- Forks: 2
- License: MIT
- Category: Developer Tools
- Maintenance: Actively Maintained
Install Role Control
bench get-app https://github.com/abdullla00/role_control
Add the Frappe Gems badge to your README
Maintain Role Control? Paste this into your README:
[](https://frappegems.com/gems/apps/abdullla00/role_control)
About Role Control
Role Control
Advanced role utilities and UI control overrides for Frappe and ERPNext.
Form Button Control
Centrally hide form and list buttons per Role and/or User, optionally scoped by Company.
Installation
cd $PATH_TO_YOUR_BENCH
bench get-app apps/role_control
bench --site install-app role_control
bench migrate
bench build --app role_control
Creating a rule
- Open Role Control workspace → Form Button Control.
- Set Role or User (at least one required).
- Optionally set Company (blank = all companies).
- Set Priority (higher wins when rules conflict).
- Add child rows:
- Reference DocType — target form (e.g.
Job Order). - View —
Form,List, orBoth. - Button Category —
Standard,Custom,Workflow, orMenu Action. - Button Label — Autocomplete suggestions from JS scan + hook registry (Custom / Menu Action); you can still type a custom label.
- Button Group — optional third argument to
add_custom_button. - Apply On Docstatus — when the rule applies on forms (
All= always).
- Reference DocType — target form (e.g.
Company matching
- On forms, the open document’s
companyfield is used when present; otherwise the user’s default Company. - On list views, the user’s default Company is used.
Dynamic button label options
For Custom and Menu Action, when you set Reference DocType, Button Label loads suggestions from:
- JS scan —
add_custom_button/add_menu_itemin doctype.js, hookdoctype_js/doctype_list_js, and enabled Client Script records. - Menu catalog — common Frappe form menu items (
Email,Duplicate,Rename, …) for Menu Action. button_control_registryhook — other apps register extra labels (registry wins over scan for the same label).
Optional: in any app's hooks.py:
button_control_registry = {
"Job Order": [
{"category": "Custom", "label": "Make Return Ticket", "group": None},
],
}
Limitations: Only literal __("Label") strings in add_custom_button calls are discovered (including multiline calls with a third-argument group). Dynamic first arguments (variables) and __("View {0}", [ref]) are not scanned; literal __("View …") labels in JS maps are listed under group Navigate. Grid add_custom_button calls (e.g. row Swap) are ignored. Override or type labels manually via the button_control_registry hook when needed.
Using the dropdown: In the child table row editor, click Button Label or Button Group (or focus the field) to load suggestions. Options are loaded via get_query when the field is focused, not as a static Select list.
Button label examples (Galiska Job Order)
| Label | Category |
|---|---|
Make Return Ticket |
Custom |
Complete Operation |
Custom |
Submit |
Standard |
Cancel |
Standard |
| Workflow transition name | Workflow |
Email |
Menu Action |
Security
Button hiding is UI-only. Users may still invoke actions via API, shortcuts, or custom scripts unless blocked by DocPerm and server-side checks. Do not rely on this app as the sole authorization layer.
Bypass
Rules do not apply when logged in as Administrator (so setup is never blocked). Rules do apply to users with the System Manager role, including rules where role = System Manager (e.g. FBC-00037).
Tests
bench --site run-tests --app role_control
Related Developer Tools apps for Frappe & ERPNext
- Frappe — Low code web framework for real world applications, in Python and Javascript
- Frappe Docker — Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development
- Builder — Craft beautiful websites effortlessly with an intuitive visual builder and publish them instantly
- Bench — CLI to manage Multi-tenant deployments for Frappe apps
- Frappe Ui — A set of components and utilities for rapid UI development
- Press — Full service cloud hosting for the Frappe stack - powers Frappe Cloud
- Gameplan — Open Source Discussions Platform for Remote Teams
- Doppio — A Frappe app (CLI) to magically setup single page applications and Vue/React powered desk pages on your custom Frappe apps.