[18.0][FIX] server_action_mass_edit: Hook view cache mechanism #1203
+51
−59
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.
With Odoo 17.0, any "dynamic" views were not correctly updated because of Odoo view cache mechanism. When this module has been migrated to 17.0, a choice has been made to create a copy of the wizard's view form and to delete it after each onchange calls based on the view name. And since the context if lost between the action call and view get query, a reference field was added to the view to retrieve the mass edit action.
But a major issue is that the inheriting mechanism is totally broken with this implementation: inherited views for the real wizard's view form are not applied on the copy (I found out while migrating https://github.com/decgroupe/odoo-addons-dec/tree/14.0/mass_editing_chat, an extension module to post a chat message to each mass edited records)
My PR to fix this issue simply revert this specific change and hooks the cache view mechanism implemented in Odoo:
viewService.loadViewsfromodoo/addons/web/static/src/views/view_service.js.Viewclass but only when xml "dev_mode" is not active:['ir.ui.view']._get_view_cache_keyfromodoo/odoo/addons/base/models/ir_ui_view.pyThe following specific key/value pair is dynamically added to the action view context and Odoo will use it in its cache key because it ends with
*_view_ref:That means that Odoo will automatically keep in cache each latest edited mass edit actions.
And the cherry on top is that we can reuse this web client context to get back the server action when the web client call
get_view.I think that this PR should be merged before 19.0 migrations #1182 #1174, and backported to 17.0 if possible.
@legalsylvain