Skip to content

Conversation

@DemchukM
Copy link

Backend UI Reload Module

This is a technical module that allows triggering a UI reload from the backend.
It enables triggering the reload action for selected users and record IDs.


🔧 Helper Function: reload_views

A special helper function reload_views is added to the res.users model.

Arguments

Argument Type Description
model Char Model name, e.g. 'res.partner'
view_types List of Char (optional) View types to reload, e.g. ["form", "kanban"]. Leave blank to reload all views.
rec_ids List of Integer (optional) The view will be reloaded only if a record with an ID from this list is present in the view.

this.render(true);
}
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think soft_reload action is better to use to reload records:

https://github.com/odoo/odoo/blob/16.0/addons/web/static/src/webclient/actions/client_actions.js#L56

We can avoid being tied to the view type and call soft reload, which updates the data without reloading the browser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can, by analogy with the web_notify module, receive a message from the backend and call doAction(“soft_reload”);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, that would be better, I've made the changes.

@JordiBForgeFlow
Copy link
Member

What if the user is making edits to that view that will be refreshed? She would use the info?

@ivs-cetmix
Copy link
Member

What if the user is making edits to that view that will be refreshed? She would use the info?

@JordiBForgeFlow yes, this may happen. This is why there is a special warning in the module description.

Copilot AI review requested due to automatic review settings November 19, 2025 16:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new technical module web_refresh_from_backend that enables backend-triggered UI view refreshes for Odoo 16.0. The module adds a reload_views helper method to the res.users model that can selectively refresh views (form, list/tree, kanban) for specific users and record IDs via the bus notification system.

Key changes:

  • Adds backend method for triggering selective view refreshes with filtering by model, view types, and record IDs
  • Implements JavaScript patches for form, list, and kanban controllers to handle bus notifications
  • Includes comprehensive test coverage for the reload functionality

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web_refresh_from_backend/__manifest__.py Module manifest declaring dependencies and JavaScript assets
web_refresh_from_backend/models/res_users.py Implements reload_views method for sending bus notifications
web_refresh_from_backend/static/src/views/form/form_controller_patch.esm.js Patches FormController to handle refresh notifications
web_refresh_from_backend/static/src/views/list/list_controller_patch.esm.js Patches ListController to handle refresh notifications
web_refresh_from_backend/static/src/views/kanban/kanban_controller_patch.esm.js Patches KanbanController to handle refresh notifications
web_refresh_from_backend/tests/test_reload_views.py Unit tests for the reload_views functionality
web_refresh_from_backend/readme/DESCRIPTION.md Module documentation describing functionality and usage
web_refresh_from_backend/readme/USAGE.md Usage examples for the reload_views method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the last commit that implements the standard 'reload' mechanism wizard windows remain opened when a refresh is called from the backend.
At the same time the form in the background is being refreshed.

Image

Before the last commit it was working fine.

Code
NB: adding

return {
            "type": "ir.actions.act_window_close",
        }

doesn't solve the issue.

Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works now. Functional review LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants