Daily updates from Odoo
Wednesday, May 20, 2020
1 change · master
New functionality added to Odoo
Studio users can now configure approval rules on form buttons, helping businesses require the right people to approve key actions before they happen. This gives small companies a simple way to add approval controls without custom development, though it applies only in form views and can be bypassed outside the web client.
Original PR description
Allow users to add approval rules on buttons through Studio. The rationale is that a lot of SMEs want to establish an approval process where doing an action on a record (typically through the use of…
Allow users to add approval rules on buttons through Studio. The rationale is that a lot of SMEs want to establish an approval process where doing an action on a record (typically through the use of a button) is limited to certain users (or must be approved by certain users). This commit add such a mechanism through the Studio application. The approval rules are stored through 2 models: - a `studio.approval.rule` model, which represents a single approval rule tied to a model and an action or method (e.g. `sale.order`/`action_confirm` or `sale.order`/298 where 298 is, say, the id of the window action of a wizard). An approval rule is linked to a group and a user can only it if they are a member of that group. - a `studio.approval.entry` model, which represents the approval (or rejection) of a rule for a specific record by a specific user. The main entry point for these models are: - `get_approval_spec` on `studio.approval.rule`, which returns a full description of the approval flow for a given action (and if the spec is requested for a specific record, also includes existing entries). - `check_approval` on `studio.approval.rule`, which checks whether the user can proceed with an action (method or action ID for a specific record); if some rules for the action have not yet been they will be automatically approved by the current user on the fly if they are allowed to approve them. - `set_approval` on `studio.approval.rule`, which records an entry for that rule (accepted or rejected) for a specific record. - `cancel_approval` on `studio.approval.rule`, which deletes an entry for that rule (accepted or rejected) for a specific record. On the client's side, several overrides have been added so that any click on a button which has been marked as being subject to approval through a `studio_approval` attribute on its node will first check server-side if the action can proceed through a call to `check_approval`; if the check is successful, the action proceeds; if not, it is stopped and a warning is displayed to the user. This commit also adds the necessary plumbing in `web_studio` to allow configuring these approval rules on any button of a form view. Current limitations of this implementation: - only buttons in form views support this mechanism - these checks are done through the web client only; a badly-intentioned user may bypass these checks through an rpc calls using their own credentials This is a simple feature made for quick and easy rules; any advanced use case should instead use automated actions based on complex rules - these will not be by-passable through rpc calls. But, for small companies that need a quick and easy way to restrict actions, this is a nice addition to Studio. Task-2092572 Community changes in odoo/odoo#48983