How to Add Button in
Chatter in Odoo 17
Enterprise
Introduction
Enterprise
This slide will explain Adding a Button to the Chatter in Odoo 17
Enterprise
Chatter
In Odoo, the "chatter" is a communication and collaboration
feature embedded in various modules, enabling users to interact
and share information within specific records. Typically located in
the form view, the chatter allows users to add notes, send
messages, and track discussions related to a particular record.
The image below displays the chatter associated with the sale
order model.
Enterprise
Enterprise
Key Aspects of the Chatter in Odoo
● Messaging and Notes: Users can post messages and
notes pertaining to a specific record, including general
information, updates, or discussions.
● Attachments: Users can attach files and documents to the
chatter, facilitating the sharing of additional information
related to the record.
Enterprise
Key Aspects of the Chatter in Odoo
● Followers: Users can follow a record to receive
notifications about any updates or changes made to that
record.
● Email Integration: The chatter often integrates with email,
allowing users to send messages directly from the chatter
interface.
● Log and History: The chatter maintains a log of all
activities and changes related to the record, providing a
comprehensive history of interactions.
Enterprise
Adding a Button to the Chatter in Odoo 17
To add a new button to the chatter interface universally, we will
extend the mail.Chatter template, setting the t-inherit-mode to
extension. This adjustment ensures that a button labeled 'Calendar'
is positioned before the activity icon across all chatter instances.
Enterprise
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="calender.Chatter" t-inherit="mail.Chatter" t-inherit-mode="extension">
<xpath expr="//*[contains(@class, 'o-mail-Chatter-activity')]" position="before">
<button class="btn btn-secondary text-nowrap me-2" t-att-class="{'my-2': !
props.compactHeight }" data-hotkey="shift+w" t-on-click="calenderEvent">
<span>Calendar</span>
</button>
</xpath>
</t>
</templates>
XML Code
Enterprise
This adds a "Calendar" button to the user interface as shown in the
image below.
Enterprise
Enterprise
JavaScript Code
To implement the functionality for the 'Calendar' button, we need to
patch the Chatter component and introduce the necessary function.
Enterprise
/** @odoo-module */
import { Chatter } from "@mail/core/web/chatter";
import { patch } from "@web/core/utils/patch";
patch(Chatter.prototype, {
async calenderEvent() {
await this.env.services.action.doAction({
type: "ir.actions.act_window",
res_model: "mail.activity",
view_mode: "form",
views: [[false, "form"]],
context: {
active_id: this.props.threadId,
model: this.props.threadModel,
},
});
},
});
Enterprise
This function utilizes the current model stored in
this.props.threadModel and the corresponding record ID in
this.props.threadId. With these values, it executes the logic and
performs the necessary operations. Specifically, this method
opens a form view for the model mail.activity, with the context
containing the active record ID and model.
By clicking the 'Calendar' button, the user can navigate to the
page, as shown in the screenshot below.
Enterprise
Enterprise
In Odoo, patching the chatter involves making adjustments or
enhancements to the communication and activity feed linked
with records. This process allows for customization and
extension of the default chatter functionality to meet specific
requirements or include additional features within the Odoo ERP
system.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides

  • 1.
    How to AddButton in Chatter in Odoo 17 Enterprise
  • 2.
    Introduction Enterprise This slide willexplain Adding a Button to the Chatter in Odoo 17
  • 3.
    Enterprise Chatter In Odoo, the"chatter" is a communication and collaboration feature embedded in various modules, enabling users to interact and share information within specific records. Typically located in the form view, the chatter allows users to add notes, send messages, and track discussions related to a particular record. The image below displays the chatter associated with the sale order model.
  • 4.
  • 5.
    Enterprise Key Aspects ofthe Chatter in Odoo ● Messaging and Notes: Users can post messages and notes pertaining to a specific record, including general information, updates, or discussions. ● Attachments: Users can attach files and documents to the chatter, facilitating the sharing of additional information related to the record.
  • 6.
    Enterprise Key Aspects ofthe Chatter in Odoo ● Followers: Users can follow a record to receive notifications about any updates or changes made to that record. ● Email Integration: The chatter often integrates with email, allowing users to send messages directly from the chatter interface. ● Log and History: The chatter maintains a log of all activities and changes related to the record, providing a comprehensive history of interactions.
  • 7.
    Enterprise Adding a Buttonto the Chatter in Odoo 17 To add a new button to the chatter interface universally, we will extend the mail.Chatter template, setting the t-inherit-mode to extension. This adjustment ensures that a button labeled 'Calendar' is positioned before the activity icon across all chatter instances.
  • 8.
    Enterprise <?xml version="1.0" encoding="UTF-8"?> <templates> <tt-name="calender.Chatter" t-inherit="mail.Chatter" t-inherit-mode="extension"> <xpath expr="//*[contains(@class, 'o-mail-Chatter-activity')]" position="before"> <button class="btn btn-secondary text-nowrap me-2" t-att-class="{'my-2': ! props.compactHeight }" data-hotkey="shift+w" t-on-click="calenderEvent"> <span>Calendar</span> </button> </xpath> </t> </templates> XML Code
  • 9.
    Enterprise This adds a"Calendar" button to the user interface as shown in the image below.
  • 10.
  • 11.
    Enterprise JavaScript Code To implementthe functionality for the 'Calendar' button, we need to patch the Chatter component and introduce the necessary function.
  • 12.
    Enterprise /** @odoo-module */ import{ Chatter } from "@mail/core/web/chatter"; import { patch } from "@web/core/utils/patch"; patch(Chatter.prototype, { async calenderEvent() { await this.env.services.action.doAction({ type: "ir.actions.act_window", res_model: "mail.activity", view_mode: "form", views: [[false, "form"]], context: { active_id: this.props.threadId, model: this.props.threadModel, }, }); }, });
  • 13.
    Enterprise This function utilizesthe current model stored in this.props.threadModel and the corresponding record ID in this.props.threadId. With these values, it executes the logic and performs the necessary operations. Specifically, this method opens a form view for the model mail.activity, with the context containing the active record ID and model. By clicking the 'Calendar' button, the user can navigate to the page, as shown in the screenshot below.
  • 14.
  • 15.
    Enterprise In Odoo, patchingthe chatter involves making adjustments or enhancements to the communication and activity feed linked with records. This process allows for customization and extension of the default chatter functionality to meet specific requirements or include additional features within the Odoo ERP system.
  • 16.
    For More Info. Checkour company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com