Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to send a private message from OdooBot to a user?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
developmentdiscuss
1 Respondre
524 Vistes
Avatar
Alex McColm

Hello all,


I am developing an Odoo extension, and I want to send a message from OdooBot to a given partner ID in Discuss. I am attempting to send myself such a message in the Odoo python shell here, and it seems to create a record, but in my browser window with the same DB, and verifying that the partner ID and channel IDs match, I still don't see the message. It even seems to be returned in a search of message records. What is missing for the message to show up properly?


I have assumed the logs about the push notification being deleted can be ignored. I have the chat window open, so it makes sense it would delete the push notification.

>>> odoobot_id = self.env.ref("base.partner_root").id

>>> channel = self.env["discuss.channel"].with_user(1).channel_get([8])

>>> channel.name

'OdooBot, Alex McColm'

>>> channel.message_post(body='HelloWorld!', author_id=odoobot_id, message_type="comment", subtype_xmlid="mail.mt_comment")

2025-10-23 17:54:34,848 1395 WARNING Odoo_Backup_2025-10-22__19-28-55.zip odoo.addons.mail.tools.web_push: Failed push notification https://fcm.googleapis.com/fcm/send/eJ32KjmxmoI:APA91bH8xugL7jxOtyXZqSGbBEaDcW5Ra0e1DD-PWnGWIzyNIhzYytvdrxwD-AvTI93P9XzKBYp8iQt8-_dS4gGywQ5K2EhjGRanBAK41ZobvUv8kx348nrmrqEoEhh51a6x_yJM0POr 410 - push subscription has unsubscribed or expired.

2025-10-23 17:54:35,054 1395 INFO Odoo_Backup_2025-10-22__19-28-55.zip odoo.models.unlink: User #1 deleted mail.push.device records with IDs: [4, 5]

mail.message(1097,)

>>> env['mail.message'].search_read(

...     [('model','=','discuss.channel'), ('res_id','=',4)],

...     ['id','author_id','body','message_type','subtype_id'],

...     limit=5, order='id desc'

... )

[{'id': 1097, 'author_id': (2, 'OdooBot'), 'body': Markup('<p>HelloWorld!</p>'), 'message_type': 'comment', 'subtype_id': (1, 'Discussions')}, {'id': 802, 'author_id': (2, 'OdooBot'), 'body': Markup('<p>Frontdesk Check-In: [redacted] (Foreseeson Technology)</p>'), 'message_type': 'comment', 'subtype_id': (1, 'Discussions')}, {'id': 47, 'author_id': (2, 'OdooBot'), 'body': Markup('<p>Hello,<br>Odoo\'s chat helps employees collaborate efficiently. I\'m here to help you discover its features.<br><b>Try to send me an emoji</b> <span class="o_odoobot_command">:)</span></p>'), 'message_type': 'comment', 'subtype_id': (1, 'Discussions')}]

>>>

0
Avatar
Descartar
Avatar
Christoph Farnleitner
Best Answer

Since your working with the odoo-bin shell:

Without committing to the database, nothing is going to be actually written to your database. Run

self.env.cr.commit()

after channel.message_post(...).

See also https://www.odoo.com/documentation/19.0/developer/reference/cli.html#shell-open-a-shell

Also, ensure you are actually a Member of the given Discuss Channel.

2
Avatar
Descartar
Alex McColm
Autor

Thank you Christoph. This is what I was missing in shell testing.

When I was using this in my extension in a function called send_private_message_as_odoobot(), I had another bug, which I'll record here in case it is useful someday. In the shell, I was passing a partner ID properly, but in the extension I was passing an hr.employee record ID.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
How to make all branches for user active automatically after login his account?
development
Avatar
Avatar
Avatar
3
de nov. 25
289
MrpBom _skip_bom_line skips line of product that has two multi-choice attribute values when both are selected in Apply to variant
development
Avatar
Avatar
1
de nov. 25
211
How to create a new field have 2 related field by developer mode
development
Avatar
Avatar
2
d’oct. 25
546
i face one error while edit my website
development
Avatar
0
d’oct. 25
659
How to add market price of the product to the Odoo 18 Community POS receipt?
development
Avatar
0
d’oct. 25
583
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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