Enable Dark Mode!
everything-you-want-to-know-about-odoo-bus-library.jpg
By: Sonu S

Everything You Want to Know About Odoo Bus Library

Technical Odoo 14 Odoo 15 Odoo 16

Odoo is a popular open-source business management software with many applications for managing various business processes such as accounting, sales, inventory and more. Odoo Bus is a messaging system that allows real-time communication between clients and servers in Odoo. The Odoo Bus library is a Python library for building real-time applications on Odoo Bus.
Odoo Bus library can be used to build real-time applications that instantly transmit and receive updates without new pages. This is done by long polling, web sockets, or SSE (Server send events), depending on the capabilities of the client and server.
Odoo Bus library is a JavaScript library that is used in Odoo to enable real-time communication between different parts of the application. It is implemented in JavaScript and is used in conjunction with other JavaScript libraries to provide a seamless user experience in Odoo.
The Odoo Bus library uses the publish/subscribe messaging pattern to enable communication between different parts of the application. This pattern is commonly used in JavaScript applications and is a powerful tool for building real-time applications.
The Odoo Bus library can be accessed in JavaScript code by importing the web. Bus module in Odoo 15, or the bus.bus module in earlier versions of Odoo. Once the library is imported, developers can use its methods to send and receive messages between different parts of the application.
bus.bus is a JavaScript module that provides access to the Odoo Bus library in versions prior to Odoo 15. 
Odoo Bus library is used to enable real-time communication between multiple parts of the Odoo application, such as communication tabs or windows from different browsers.
Bus.bus module can be used to register channels identified by specific names and receive messages in channels in real time.
It can also be used to create channel messages received by all users of that channel. Here is an example of how to register a channel and receive messages using
Bus.bus:
odoo.define('my_module', function (require) {
    var bus = require('bus.bus').bus;
    bus.on('my_channel', this, function (message) {
        console.log('Received message:', message);
    });
});
In this example, the code listens to the "my channel" channel and logs into the console. Here is an example of how to use
Bus.bus to process messages on a channel:
odoo.define('my_module', function (require) {
    var bus = require('bus.bus').bus;
    bus.trigger('my_channel', {
        message: 'Hello, world!'
    });
});
In this example, the code "hello world!" on "my channel" channel. All subscribers of the channel "My Channel" will receive this message.
web.Bus is a JavaScript module in Odoo that provides access to the Odoo Bus library. web.Bus module can be used to register channels identified by specific names and receive messages in channels in real time. It can also be used to make messages in the channel that will be received by all users of that channel.
An example of subscribing to a channel and receiving messages using web.Bus:
odoo.define('my_module', function (require) {
    var Bus = require('web.Bus').bus;
    Bus.on('my_channel', this, function (message) {
        console.log('Received message:', message);
    });
});
In this example, the code listens to the "my channel" channel and logs into the console.
Here is an example of how you can create a message on a channel using
Web.Bus:
odoo.define('my_module', function (require) {
    var Bus = require('web.Bus').bus;
    Bus.trigger('my_channel', {
        message: 'Hello, world!'
    });
});
Overall, the Odoo Bus library is an essential part of the Odoo JavaScript framework, and is extensively used in Odoo to enable real-time communication between different parts of the application.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message