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 send a private message from OdooBot to a user?

S'inscrire

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

Cette question a été signalée
developmentdiscuss
1 Répondre
501 Vues
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
Ignorer
Avatar
Christoph Farnleitner
Meilleure réponse

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
Ignorer
Alex McColm
Auteur

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.

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 make all branches for user active automatically after login his account?
development
Avatar
Avatar
Avatar
3
nov. 25
267
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
nov. 25
191
How to create a new field have 2 related field by developer mode
development
Avatar
Avatar
2
oct. 25
535
i face one error while edit my website
development
Avatar
0
oct. 25
654
How to add market price of the product to the Odoo 18 Community POS receipt?
development
Avatar
0
oct. 25
569
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