[17.0][ADD] bus_record_events: New Module(s) #3396
Open
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.
📝 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.