[17.0][ADD] bus_record_events: New Module(s)#3396
Conversation
c3fde21 to
664b015
Compare
664b015 to
ee9fe49
Compare
|
Hey @zamberjo thank you for your contribution! Some notes:
|
|
Hi @ivs-cetmix thanks for the comment! Just to clarify an important point: PR #3396 is not equivalent to #3363, even though both deal with UI updates from backend changes. #3363 (web_refresh_from_backend) focuses on forcing view reloads from the backend and requires manual integration in the backend code where a refresh is needed. #3396 (bus_record_events) introduces an event-driven approach based on the bus, providing mixins, services, and OWL hooks so the UI can react to record changes. It enables automatic view refresh out of the box and allows building more fine-grained, near real-time reactive views beyond full reloads. |
|
@ivs-cetmix hi! Just a friendly ping to check whether you’ve had a chance to review this PR. Any feedback would be very welcome. Thanks! |
|
Hi @zamberjo , I did some check, however I'm not skilled enough on JS part to do a technical review. Let's ping @OCA/web-maintainers , probably they can have a look at it. |
📝 TL;DR
Real-time UI synchronization for Odoo 17
Say goodbye to manual F5 and the legacy patterns of web_refresher. This module introduces a clean, bus-based approach to keep views updated across different sessions automatically. By using a backend mixin and a dedicated OWL hook (useRecordStream), developers can now ensure users always see the latest data without the overhead of constant polling or manual reloads. A simple way to make Odoo feel more collaborative and reactive.
Grabacion.de.pantalla.desde.2025-12-19.20-38-17.webm
This PR introduces three new modules designed to bring real-time reactivity to Odoo views via the Bus system:
bus_record_events: The core module. It provides a mixin (bus.record.event.mixin) that broadcasts CRUD operations (create, write, unlink) to the Odoo Bus. It also includes specialized JS classes for views (Form, Kanban, List, etc.) that listen to these events and update the interface automatically.bus_record_events_all: An extension that automatically applies the mixin to all models in the system and injects the reactive JS classes into views globally.bus_record_events_demo: Contains demo data and examples to showcase the functionality.Testing Instructions:
To verify the functionality using the demo module (
bus_record_events_demo):bus_record_events_demomodule is installed.JavaScript API:
This module exposes tools for developers to build reactive OWL components easily:
bus_record_event_service: A new service that manages the subscription to record_events channels. It handles the underlying bus connection and dispatches notifications to subscribers.useRecordStream: A custom OWL hook designed to simplify component integration. It automatically handles the lifecycle of the subscription (adding channels ononWillStart, unsubscribing ononWillUnmount) and provides callbacks for common actions:onReload: Triggered when a record changes (useful for refreshing views).isDirty: Checks if the current view has unsaved changes before acting.onUpdate: Allows custom handling of the event payload.Example Usage
Design Decision regarding
bus_record_events_all:We considered including the global broadcasting functionality directly within the core
bus_record_eventsmodule, controlled by anir.config_parameter(defaulting toFalse). However, this approach would require checking the system parameter during every single CRUD operation across the entire system, which raised concerns about potential performance overhead.To ensure the core module remains lightweight and performant, we decided to isolate this functionality into a separate module (
bus_record_events_all). This approach avoids unnecessary checks in the CRUD methods and gives administrators explicit control over enabling this resource-intensive feature simply by installing or uninstalling the module.