Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
developmenteventeventsbus
3 Respuestas
11928 Vistas
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
Descartar
Avatar
Javier García Fillol
Mejor respuesta

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
Descartar
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
Mejor respuesta

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
Descartar
Avatar
Mr Discovery
Mejor respuesta

did you ever find an answer?

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How to get the event to take up the entire webpage?
event events v15
Avatar
Avatar
Avatar
Avatar
4
abr 25
5285
Execute code after Event Ticket Confirmation v16
event sale.order events
Avatar
0
jun 24
1886
Event app - Change hyperlink on social media icons
hyperlink event events
Avatar
Avatar
1
dic 23
3102
Autoconfirm event ticket only after payment success. v16
payment event sale.order events
Avatar
0
jun 24
2118
i want add content to email
event events Event Evento
Avatar
Avatar
2
may 24
2086
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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