Enable Dark Mode!
By: Ranjith R

How to Add Action in Discuss Chatter Messages in Odoo 17

Technical Odoo 17

In Odoo 17, the Discuss module plays a crucial role in facilitating communication and collaboration within the system. The Chatter is commonly associated with various Odoo modules like CRM, Sales, and Project Management, allowing users to communicate and share information directly within records. To further enrich the user experience and extend the capabilities of Chatter messages, the platform provides the flexibility to introduce custom actions.

Custom actions empower users to perform specific operations or trigger workflows directly from Chatter messages. These actions are provided to meet the unique requirements of the business or organization using Odoo. The provided code snippet illustrates how developers can leverage the extensibility features of Odoo 17 to add a custom action within Chatter messages.


How to Add a Custom Action in Chatter Messages Odoo 17

Patching Message Class And Add Function.

The patch function is used to extend the functionality of the Messageclass, allowing developers to introduce additional methods and properties..

/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";
import { Message } from "@mail/core/common/message";
patch(Message, {
components: { ...Message.components },
patch(Message.prototype, {
setup() {
    this.orm = useService("orm");
async createLead() {
    var self= this
    await this.orm.call(
        "mail.message", "action_create_lead",
        [this.message.id], {}).then(function(data) {
                      res_model: 'crm.lead',
                      res_id: data,
                      target: "current",
                      type: "ir.actions.act_window",
                      views: [[false, "form"]],

Here a function “createLead” is added to the “Message” class which creates a lead with the message text. The supporting Python function is given below.

class MailMessage(models.Model):
_inherit = 'mail.message'
def action_create_lead(self):
    """ Action to view Facebook comments associated with the feed."""
    lead = self.env['crm.lead'].create({
        'name': self.preview,
        'type': 'lead',
        'user_id': self.env.user.id,
        'partner_id': self.author_id.id,
        'contact_name': self.author_id.name,
        'fb_user_id': self.email_from,
    return lead.id

Registering Message Action

/* @odoo-module */
import { _t } from "@web/core/l10n/translation";
Import{ messageActionsRegistry }from"@mail/core/common/message_actions";
messageActionsRegistry.add("create_lead", {
condition: (component) => component.canReplyTo,
icon: "fa-check",
title: () => _t("Convert to Lead"),
onClick: (component) => component.createLead(),
sequence: 0,

Action Configuration:

* condition: (component) => component.canReplyTo: Specifies a condition under which the action should be visible. In this case, it depends on the canReplyTo property of the component.

* icon: "fa-check": Sets the icon for the action. Here, it's using the Font Awesome icon "fa-check."

* title: () => _t("Convert to Lead"): Defines the title of the action, which is translated using the _t  function. The title is "Convert to Lead."

* onClick: (component) => component.createLead(): Specifies the function to be executed when the action is clicked. In this case, it calls the createLead method on the component.

* sequence: 0: Sets the sequence or priority of the action. Actions with lower sequence numbers appear first.

In conclusion, custom actions in Odoo 17's Discuss module empower users to perform specific tasks directly within Chatter messages. By extending the Message class and configuring actions, developers can enhance the platform's functionality. In this example, we demonstrated how to add a straightforward "Convert to Lead" action, showcasing the flexibility of Odoo 17 in meeting unique business needs. Custom actions streamline workflows, boost user productivity, and make Chatter a more dynamic and tailored tool for efficient collaboration within the Odoo ecosystem.

To read more about adding a button in Chatter in Odoo 17, refer to our blog How to Add a Button in Chatter in Odoo 17

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message