Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

How to send a real-time notification to POS UI using bus.bus in Odoo 17?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
odoo17
1 Responder
5013 Visualizações
Avatar
abdallah

Hello Odoo Community,

I'm working on Odoo 17 and trying to send a real-time notification to the Point of Sale (POS) interface using the bus.bus service.

 My goal:

When an admin user presses a button (from backend), a message should be pushed to all open POS sessions so that the cashier sees a notification popup on their screen.

 What I tried:


1. POS Frontend Code (Patch):

/** @odoo-module **/

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

import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";


patch(ProductScreen.prototype, {

    setup() {

        super.setup();

        const bus_service = this.env.services.bus_service;

        const notification = this.env.services.notification;


        const channel = JSON.stringify(["pos.custom.notification", "global"]);

        bus_service.addChannel(channel);


        onMounted(() => {

            bus_service.addEventListener("notification", ({ detail }) => {

                for (const { type, payload } of detail) {

                    if (type === "custom_alert") {

                        notification.add(payload.message, {

                            title: payload.title || "POS Notice",

                            type: "info",

                        });

                    }

                }

            });

        });

    },

});



2. Python Backend Code:

python

from odoo import models, _

from odoo.exceptions import UserError


class ResUsers(models.Model):

    _inherit = 'res.users'


    def action_notify_pos_cashier(self):

        self.env['bus.bus']._sendone(

            (self.env.cr.dbname, 'pos.custom.notification', 'global'),

            self.env.uid,

            {

                'type': 'custom_alert',

                'title': '🔔 POS Alert',

                'message': '📢 Hello from the backend!'

            }

        )



What’s happening:


  • I see in the browser console that the POS is subscribed to the correct channel.

  • However, when I call the backend method (action_notify_pos_cashier()), nothing is received on the frontend.

  • No errors are shown in the frontend, and the channel is active.

My Question:

What is the correct way to structure a real-time notification from the backend to POS using bus.bus in Odoo 17 (OWL2 + POS OWL)?

Am I missing something in how the channel should be defined or how the payload is passed?

Additional info:


  • Odoo version: 17.0 (Community)


JS code loaded via custom module using patch

Any guidance or working example would be greatly appreciated 🙏

0
Avatar
Cancelar
Avatar
D Enterprise
Melhor resposta
Fix the Backend Code:

Replace _sendone(...) with _sendmany([...]) and remove "global" unless you have logic in place that matches it exactly on the frontend.
def action_notify_pos_cashier(self):

    self.env['bus.bus']._sendmany([

        (

            "pos.custom.notification",  # No db prefix

            {

                'type': 'custom_alert',

                'title': '🔔 POS Alert',

                'message': '📢 Hello from the backend!',

            }

        )

    ])

final code 
/** @odoo-module **/


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

import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";

import { onMounted } from "@odoo/owl";


patch(ProductScreen.prototype, {

    setup() {

        super.setup();


        const bus_service = this.env.services.bus_service;

        const notification = this.env.services.notification;


        const channel = JSON.stringify(["pos.custom.notification"]);

        bus_service.addChannel(channel);


        onMounted(() => {

            bus_service.addEventListener("notification", ({ detail }) => {

                for (const { type, payload } of detail) {

                    if (type === "custom_alert") {

                        notification.add(payload.message, {

                            title: payload.title || "POS Notice",

                            type: "info",

                        });

                    }

                }

            });

        });

    },

});


0
Avatar
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
Error while posting invoice to ZATCA odoo sh Resolvido
odoo17
Avatar
Avatar
Avatar
Avatar
3
jul. 25
3008
Odoo time-sheets rights to add
odoo17
Avatar
Avatar
2
mai. 25
2961
POS is not recognizing short barcodes like "95" or "96" (Code 39 or custom short codes)
odoo17
Avatar
1
mai. 25
2011
Odoo 17
odoo17
Avatar
1
fev. 25
40
Existing Field Labels not displayed after installing new module
odoo17
Avatar
Avatar
1
fev. 25
2505
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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