Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to setup (real-time) communication between client and server using bus service in Odoo 18

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
problembugfix
3 Antworten
8906 Ansichten
Avatar
Jan van der Wel

Hi all,

Can some help to setup communication between server and client, where I want to update the standard progresBarField in real-time:


/** @odoo-module **/

import { registry } from "@web/core/registry";

import { patch } from "@web/core/utils/patch";

import { ProgressBarField } from "@web/views/fields/progress_bar/progress_bar_field";

const fieldRegistry = registry.category("fields");

console.log("Progress listener setup");

patch(ProgressBarField.prototype, {

    setup() {

        super.setup();

        console.log("Setup progress bar");

        this.busService = this.env.services.bus_service;

        console.log("busService active is %B", this.busService.isActive);

        this.channel = "progress_bar_channel";

        this.busService.addChannel(this.channel);

        this.busService.addEventListener("notification", this.onBusMessage.bind(this));

    },

    onBusMessage({detail: notifications}) {

        console.log("onBusMessage", notifications);

        notifications = notifications.filter(item => item.type === 'notification')

        notifications.forEach(item => {

           console.log("Progress: %d on field %s", item.payload.progress, item.payload.field);

           this.setProgress(item.payload.field, item.payload.progress);

        })

    }, 

    setProgress(fieldName,newProgress) {

        if (newProgress >= 0 && newProgress <= 100) { // Ensure the progress is within bounds

            console.log("newProgress", newProgress);

            let value = String(newProgress);

            this.onValueChange(value, fieldName);

       }

    }

});  

At the Odoo server side I send progress information from a Model in Python as follows:

class MyImportWizard(models.TransientModel):

    _name = 'myapp.import.wizard'

    _description = 'Import Wizard '

    _inherit = ['bus.listener.mixin'] # Inherit the mixin for bus notifications

    file = fields.Binary("Select File", required=True, file_name = fields.Char()

    progress = fields.Integer(string="Progress", default=0)   


    def import_file(self):

        records = self.env['myapp.data'].search([])

        rows_to_process = records.__len__()

        rows_processed = 0

        for record in records:

            .... # Do some model and other model and database update work

            rows_processed = rows_processed + 1

            self.progress = (int)((rows_processed * 100) / rows_to_process)

            self.env['bus.bus']._sendone('progress_bar_channel', 'notification',

                                             {'field': 'progress','progress': self.progress})                                                       

            self.env.cr.commit(). # Needed in Odoo 17 to release (send) bus messages to the client


        self.progress = 100 # Complete the task

        self.env['bus.bus']._sendone('progress_bar_channel', 'notification',

                                             {'field': 'progress', 'progress': self.progress})


What changed in Odoo 18, that this is not working anymore. I see a lot of guessing work and changes over the different Odoo versions, where the Bus (bus.bus) API changed from version to version. In Odoo 17 I see all the console messages in the browser. In both Odoo 17 and 18 the bus_service is seen as active.

Can someone provide a good and working example on how this should work for Odoo 18 

Thanks for your help and I hope that the answer contributes to a better Odoo



2
Avatar
Verwerfen
Avatar
Jan van der Wel
Autor Beste Antwort

Hi finally I solved it as follows because Odoo 18 is quite different especially at frontend by using OWL better. By this code you have a simple progress bar when uploading a large amount of data in the database.

At the frontend using OWL:

import { patch } from "@web/core/utils/patch";

import { ProgressBarField } from "@web/views/fields/progress_bar/progress_bar_field";

import { useService, useBus } from "@web/core/utils/hooks";


console.log("Progress listener setup");


patch(ProgressBarField.prototype, {

setup() {

super.setup();

console.log("Setup progress bar");


this.busService = useService("bus_service");


this.busService.subscribe("progress_update", (payload, {id: notifyID}) => {

const {progress: progress, field: field} = payload;

console.log("Progress: %d for field %s", progress, field);

this.setProgress(field, progress)

});

this.busService.start();

},


setProgress(fieldName,newProgress) {

if (newProgress >= 0 && newProgress <= 100) { // Ensure the progress is within bounds

console.log("newProgress", newProgress);

let value = String(newProgress);

this.onValueChange(value, fieldName);

}

}

});


At the backend:

rows_processed = rows_processed + 1

self.progress = (int)((rows_processed * 100) / rows_to_process)

self.env.user._bus_send("progress_update", {

'field': "progress",

'progress': self.progress,

})

self.env.cr.commit()

So thank you all for your response and maybe it helps you.

0
Avatar
Verwerfen
Avatar
Maurel Reyes
Beste Antwort

En odoo 18 no funcionaba, tube que pasar el partner_id en vez del canal, solicitud realizada desde un controlador

user_list = request.env['res.users'].search([])
for current_user in user_list:
​request.env["bus.bus"]._sendone(current_user.partner_id, "turno.new_ticket", message)

0
Avatar
Verwerfen
Avatar
Adam Heinz
Beste Antwort

I am also struggling with this, but have made some progress receiving messages from a non-custom Odoo channel:

setup() {

this.bus = useService("bus_service");

this.bus.subscribe("bus.bus/im_status_updated", message => console.log("received", message));

}

yields logs in the browser console

received Object { im_status: "online", partner_id: 3 }

Unfortunately, when I attempt to manually send messages using odoo shell​, I don't see anything in my browser console.

self.env['bus.bus']._sendone('odoo-presence-res.partner_3', 'bus.bus/im_status_updated', {'im_status': 'away'})


0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
my website is deleted.
problem
Avatar
Avatar
1
Mai 24
2113
Problema - Cierre de PTV
problem
Avatar
Avatar
1
Juni 23
3152
Why can't i use free versions? Gelöst
bugfix
Avatar
Avatar
1
Okt. 22
2197
How to install pysftp in Odoo 18 App on TrueNAS SCALE (App Store Deployment)?
problem pysftp
Avatar
Avatar
1
Juli 25
1321
Odoo 17 Disconnect when Printing
debug problem
Avatar
Avatar
Avatar
Avatar
4
März 24
3585
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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