Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to use bus to send events from backend to user's browser?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
developmenteventeventsbus
3 Réponses
11861 Vues
Avatar
Artur Roszczyk

I am trying to implement a component which displays in Systray currently running task in timer.timer model (Odoo 15 Enterprise)

I've extended the model to send a payload to trigger an action in the component


class TimerTimer(models.Model):
  _inherit = 'timer.timer'

  def create(self, vals):
    record = super(TimerTimer, self).create(vals)
    self.env['bus.bus']._sendone(record.user_id.partner_id, "timer.timer/updated", {})
    return record

  def write(self, vals):
    record = super(TimerTimer, self).write(vals)
    self.env['bus.bus']._sendone(self.user_id.partner_id, "timer.timer/updated", {})
    return record

I can see the payload incoming to browser via poll request. Now, how to subscribe to it in my component? I've tried this:


class Timer extends Component {
    setup() {
        let self = this
        console.log("EventBus")
        console.log(self\.env\.bus\)
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \  \    \   useBus\(self.env.bus, "timer.timer/updated", event => {
            console.log(event)
        })
}
Timer.template = "eaxpl_timesheet_timer.Timer"
registry.category("systray").add("eaxpl_timesheet_timer.Timer", { Component: Timer }, { sequence: 3 });

export default Timer

Unfortunately it does not seem to work. The event bus object is there but it does not seem to catch the payload incoming. I have tried listening on:

  • timer.timer/updated
  • notification

Any hints appreciated


0
Avatar
Ignorer
Avatar
Javier García Fillol
Meilleure réponse

Finally i got it, after 3 days of work and research..


In front end for example for create a new custom channel
/** @odoo-module **/
// BusListener.js
import { registry } from"@web/core/registry";
constmyService= {    dependencies: ['bus_service'],    start(_, { bus_service }) {        console.log('Add notification')
        bus_service.addChannel('my-event') // New channel
        bus_service.addEventListener('notification', ({ detail: notifications }) => {            console.log({ notifications })            for (const { payload, type } ofnotifications) {                if (type==="my-event") {                    this.myEventHandler(payload)                }            }        });
        bus_service.addEventListener('connect', () => {            console.log('Connected')        });
        bus_service.start();
    },
    myEventHandler(event) {        console.log({ event });    }};
registry.category("services").add("myService", myService);
In backend:

# -*- coding: utf-8 -*-fromodooimportmodels, fields, api
classBusModel(models.Model):    _name='bus_test'    _description="Bus para my modulo"
    name=fields.Char(string="Name")
    @api.model    defmy_method(self):        self.env['bus.bus']._sendone('my-event', 'my-event', {            'server_version': "my-event"        })
0
Avatar
Ignorer
Javier García Fillol

Odoo forum for developers the forum can't paste a code of developers, it is a shit of post system

Avatar
Adam Heinz
Meilleure réponse

setup() {

this.env.bus.on('WEB_CLIENT_READY', null, async () => {

const bus_service = owl.Component.env.services.bus_service;

bus_service.onNotification(this, this._onNotification);

bus_service.addChannel(/* record.user_id.partner_id */);

bus_service.startPolling();

});

}

Sorry for formatting, this web editor is terrible. Grep 15.0 for plenty of examples of what _onNotification looks like.

0
Avatar
Ignorer
Avatar
Mr Discovery
Meilleure réponse

did you ever find an answer?

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How to get the event to take up the entire webpage?
event events v15
Avatar
Avatar
Avatar
Avatar
4
avr. 25
5277
Execute code after Event Ticket Confirmation v16
event sale.order events
Avatar
0
juin 24
1883
Event app - Change hyperlink on social media icons
hyperlink event events
Avatar
Avatar
1
déc. 23
3097
Autoconfirm event ticket only after payment success. v16
payment event sale.order events
Avatar
0
juin 24
2112
i want add content to email
event events Event Evento
Avatar
Avatar
2
mai 24
2078
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now