Advanced role utilities and UI control overrides for Frappe and ERPNext.
Centrally hide form and list buttons per Role and/or User, optionally scoped by Company.
cd $PATH_TO_YOUR_BENCH
bench get-app apps/role_control
bench --site <site> install-app role_control
bench migrate
bench build --app role_control- 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.
- 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.
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).
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 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.
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).
bench --site <site> run-tests --app role_control