[19.0][ADD] web_action_binding_refresh - #3655
Closed
moylop260 wants to merge 1 commit into
Closed
Conversation
Creating a contextual action does not make it appear in the Actions menu of the model it is bound to. The toolbar of a view is built server side from the action bindings and travels inside the get_views response, which the web client caches in IndexedDB since 19.0. Core invalidates that cache on writes to ir.ui.view and ir.filters only, so binding an action leaves the cached entry in place. In 18.0 the cache was a plain in-memory object rebuilt on every page load, which hid the missing invalidation behind a refresh. Odoo was asked to add the invalidation in core in odoo/odoo#286419 and declined, answering that reloading the webclient is the expected behaviour and that creating a server action is too rare a flow to carry the extra code: odoo/odoo#286419 (comment) The module publishes the CLEAR-CACHES event that rpc.js already consumes, so it patches nothing in core.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New module: Web Action Binding Refresh.
Creating a contextual action does not make it appear in the Actions menu of the
model it is bound to, and reloading does not obviously fix it either.
Cause
The view toolbar is built server side from the action bindings and travels inside
get_views. Since 19.0 the web client serves that response from a cache persisted inIndexedDB (
view_service.js#L98-L102) and invalidates itfor
ir.ui.viewandir.filtersonly (#L47-L54).ir.actions.serveris not in that list, and the Create / Remove Contextual Actionbuttons call
create_action/unlink_actionthroughcall_button, so they are notin
UPDATE_METHODSeither. Binding an action therefore never invalidatesget_views.In 18.0 the same cache was a plain in-memory object rebuilt on every page load, so a
refresh hid the missing invalidation. That is why this only surfaces now.
What the module does
It adds the listener core does not register, for the four action models. It patches
nothing:
rpcBusis exported by@web/core/network/rpcandCLEAR-CACHESisalready consumed there at
rpc.js#L85-L87, which callsRPCCache.invalidateand clears both the IndexedDBand the RAM cache. The module only publishes the event core does not publish for
action models, so it survives an upstream version bump untouched.
Why not in core
Proposed as odoo/odoo#286419 and declined — the maintainer's answer:
A legitimate call for core. This module is for the installations that would rather
not reload.
Status
The server side is measured:
get_bindingsandget_views(toolbar=True)both returna newly bound action immediately, so the stale data is entirely client side.
The listener itself has not been exercised in a browser yet — flagging that
honestly rather than claiming a test I have not run.
Closed since that I'm not able to reproduce it anymore