| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 180 |
| Technical Name |
smile_dynamic_action_visibility |
| License | AGPL-3 |
| Website | https://www.smile.fr |
Smile Dynamic Action Visibility
This module allows administrators to dynamically control the visibility of Actions and Reports in Odoo based on record conditions. It replaces static, hardcoded visibility rules with a flexible, database-driven rule engine.
Visibility rules are evaluated at runtime using Python expressions and are fully compatible with Odoo 18 and the OWL framework.
Table of contents
Features
- Dynamic Action Control: Show or hide server actions dynamically.
- Report Visibility: Control availability of print reports in the UI.
- Expression-Based Rules: Use Python expressions evaluated on the active record.
- Multi-Record Support: Works in list views; if any selected record satisfies the rule, the action is hidden.
- Model-Specific Rules: Bind actions to specific models.
- OWL-Compatible: Fully integrated with Odoo 18 ActionMenus.
- Safe Evaluation: Conditions are evaluated in a sandboxed environment.
- Graceful Fallback: UI remains functional even if rule evaluation fails.
Usage
- Go to Settings > Technical > Actions > Action Rules.
- Create a new rule and define a Name.
- Select the Target Model.
- Select the Action or Report to control.
-
Define the Condition using a Python expression.
When the condition evaluates to
True, the action or report will be hidden.record.state == 'draft'→ hide when the record is in draftrecord.amount_total > 10000→ hide for high-value records
- Save the rule. The visibility is updated automatically in the UI.
Note: * If no active record exists (e.g., list view without selection), all actions having rules defined for the model are hidden. * In multi-record selection, if any record satisfies the condition, the related action/report is hidden.
Examples
-
Draft Protection:
Hide the Confirm action on
sale.orderwhenrecord.state == 'done'. -
Conditional Reports:
Hide invoice print reports when
record.state != 'posted'. - Workflow Enforcement: Hide cancellation actions once a document is validated.
-
Financial Control:
Hide high-impact actions when
record.amount_total > 50000.
Technical Details
-
Backend Engine:
Rules are stored in the
dynamic.action.rulemodel. -
Evaluation:
Conditions are evaluated using Python
evalin a sandboxed context, exposing only therecordvariable. -
RPC Integration:
The method
get_invisible_action_ids()is called by the web client to filter actions. -
OWL Patch:
The
ActionMenusOWL component is patched to dynamically remove invisible actions and reports from dropdowns. - Performance: Invisible action IDs are computed once per interaction and filtered client-side for efficiency.
Bug Tracker
Bugs are tracked on GitHub Issues .
Credits
Contributors
- Younes EL AHRACH
- Smile SA Development Team
Maintainer
This module is maintained by Smile SA.
Since 1991, Smile has been a pioneer of technology and the European expert in open source solutions.
Please log in to comment on this module