-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[ADD]web_refresh_from_backend: Refresh views from backend #3363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
[ADD]web_refresh_from_backend: Refresh views from backend #3363
Conversation
| this.render(true); | ||
| } | ||
| }, | ||
| }); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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”);
There was a problem hiding this comment.
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.
|
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. |
There was a problem hiding this 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.
web_refresh_from_backend/static/src/views/list/list_controller_patch.esm.js
Outdated
Show resolved
Hide resolved
web_refresh_from_backend/static/src/views/kanban/kanban_controller_patch.esm.js
Outdated
Show resolved
Hide resolved
ivs-cetmix
left a comment
There was a problem hiding this 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.
Before the last commit it was working fine.
Code
NB: adding
return {
"type": "ir.actions.act_window_close",
}doesn't solve the issue.
ivs-cetmix
left a comment
There was a problem hiding this 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
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_viewsA special helper function
reload_viewsis added to theres.usersmodel.Arguments
Char'res.partner'List of Char(optional)["form", "kanban"]. Leave blank to reload all views.List of Integer(optional)