Skip to content

[18.0][FIX] server_action_mass_edit: Hook view cache mechanism#1203

Open
ypapouin wants to merge 1 commit into
OCA:18.0from
decgroupe:18.0-fix-mass-edit-view-cache-hook
Open

[18.0][FIX] server_action_mass_edit: Hook view cache mechanism#1203
ypapouin wants to merge 1 commit into
OCA:18.0from
decgroupe:18.0-fix-mass-edit-view-cache-hook

Conversation

@ypapouin

Copy link
Copy Markdown
Contributor

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:

  • We force the web client to fetch updated view by adding a specific cache value in context.
  • Odoo's web client automatically sanitize the context and only keeps specific values that will be used as a cache key.
    • You can take a look on cache key mechanism in viewService.loadViews from odoo/addons/web/static/src/views/view_service.js.
    • Also note that the same cache mechanism is used in server View class but only when xml "dev_mode" is not active: ['ir.ui.view']._get_view_cache_key from odoo/odoo/addons/base/models/ir_ui_view.py

The 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:

context["nocache_server_action_mass_edit_view_ref"] = {
    "write_date": fields.Datetime.to_string(self.write_date),
    "server_action_id": self.id,
}

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

@ypapouin ypapouin force-pushed the 18.0-fix-mass-edit-view-cache-hook branch from db2e124 to 0517929 Compare June 15, 2026 06:57
@OCA-git-bot OCA-git-bot added series:18.0 mod:server_action_mass_edit Module server_action_mass_edit labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:server_action_mass_edit Module server_action_mass_edit series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants