Search code examples
odooodoo-15

How to update js template from server side in odoo15?


I have a template "muk_web_theme.AppsBar"

<templates xml:space="preserve">

    <t t-name="muk_web_theme.AppsBar" owl="1">
        ...
    </t>

</templates>

i have some counters inside (message counters) and i want to re-render this template for some users when python function was called. how i can do this from python class?

i think, that self.env['bus.bus'] can help, but i can't figure it out yet.


Solution

  • That will be tricky.

    • To do that you will need to send a bus message over a new channel.

    • Add that new channel to the HTTP Controllers in order to be retrieved by the UI

    • Extend the bus in the js to listen and process the messages you sent over the new channel

    And after that communication line it's established you could start sending messages over the channel when the values changes to communicate it to the UI to render the template to show it visually to the user

    Hope this helps