SlideShare a Scribd company logo
How to Add Button in Chatter in
Odoo 18
Enterprise
Enterprise
Improving user experience in Odoo often involves customizing the
chatter, a central hub for communication and updates on specific
records. Adding custom buttons can streamline operations, enabling
users to trigger workflows or generate reports directly. This guide
outlines the steps to add a button to the chatter in Odoo 18,
providing code snippets to help you customize this functionality for
your business needs efficiently.
Introduction
Enterprise
Step 1: Create the Button in the Chatter
To introduce a button in the chatter, you'll need to create a new template
that extends the existing mail chatter template. Here’s how to do this:
Enterprise
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="important.Chatter" t-inherit="mail.Chatter"
t-inherit-mode="extension">
<xpath expr="//*[contains(@class, 'o-mail-Chatter-activity')]"
position="before">
<button class="btn btn-warning text-nowrap me-2"
t-att-class="{'my-2': !props.compactHeight }"
data-hotkey="shift+i"
t-on-click="markAsImportant">
<span>Mark as Important</span>
</button>
</xpath>
</t>
</templates>
Enterprise
This code snippet adds a "Mark as Important" button to the chatter. The
XML template extends the existing mail.Chatter, inserting the button in the
activity area with a warning color and a keyboard shortcut (Shift+i). When
clicked, the button triggers the markAsImportant JavaScript method.
Enterprise
Step 2: Define the Button's Functionality
Next, you need to implement the functionality that occurs when the button
is clicked by enhancing the Chatter component with a new method.
Enterprise
/** @odoo-module **/
import { Chatter } from "@mail/chatter/web_portal/chatter";
import { patch } from "@web/core/utils/patch";
patch(Chatter.prototype, {
async markAsImportant() {
await this.env.services.action.doActionButton({
type: "object",
resModel: this.props.threadModel,
resId: this.props.threadId,
name: "action_mark_as_important",
});
},
});
Enterprise
This code defines the markAsImportant function that will be triggered when
the button is clicked. It utilizes the patch function from Odoo’s core utilities
to enhance the existing Chatter functionality, allowing the button to trigger
a specific server-side action. The resModel and resId parameters
dynamically refer to the current model and record ID, while
action_mark_as_important indicates the server-side method to be executed.
Enterprise
Step 3: Implement the Logic in Your Model
Now, define the logic that updates the record when the button is clicked. For
this example, we will modify the sale.order model. Add the following code to
sale_order.py file.
Enterprise
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
important = fields.Boolean("Important", default=False)
def action_mark_as_important(self):
"""Mark the record as important and post a message in chatter"""
for record in self:
record.important = True
record.message_post(
body="This record has been marked as important.")
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
Enterprise
In this code, we create a Boolean field named important and define the
action_mark_as_important method. This method marks the record as
important and posts a message in the chatter.
Enterprise
Step 4: Add the Field to the View
To ensure that the new field appears in the form view, add it to the
appropriate view definition. Include the following XML code to add the field
in the sale.order form view
Enterprise
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sale_order_view_form" model="ir.ui.view">
<field name="name">sale.order.view.form.inherit.chatter.button</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="date_order" position="after">
<field name="important" invisible="1"/>
</field>
</field>
</record>
</odoo>
Enterprise
This code adds the important field to the sale.order form, while keeping it
invisible.
Step 5: Update the Manifest File
Don’t forget to update the __manifest__.py file of your custom module to
include the newly created XML and JavaScript files.
Enterprise
Enterprise
Enterprise
Conclusion
By following these steps, you will have successfully added a button to the
chatter in Odoo 18. Clicking the "Mark as Important" button updates the
important field and posts a message in the chatter.
This functionality allows users to trigger specific actions directly from the
record's communication hub, enhancing interactions within the platform.
Customizing the chatter opens up numerous possibilities for improving user
experiences in Odoo.
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

More Related Content

DOCX
How To Add A Custom Button To The Chatter In Odoo 18 ?
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
PPTX
Report Actions In Odoo 17 - Odoo 17 Slides
PPTX
Customization of Odoo 17 Periodic Digest parameters from backend
PPTX
How To Create Record From Code In Odoo 17
PPT
Open ERP Version 7 Functional & Technical Overview
PPTX
How to Create & Configure Server Actions in the Odoo 18
PPTX
How to modify_create components control buttons in Pos odoo.pptx
How To Add A Custom Button To The Chatter In Odoo 18 ?
How to Add a Custom Button in Odoo 18 POS Screen
Report Actions In Odoo 17 - Odoo 17 Slides
Customization of Odoo 17 Periodic Digest parameters from backend
How To Create Record From Code In Odoo 17
Open ERP Version 7 Functional & Technical Overview
How to Create & Configure Server Actions in the Odoo 18
How to modify_create components control buttons in Pos odoo.pptx

Similar to How to Add Button in Chatter in Odoo 18 - Odoo Slides (20)

PPTX
Customer Automation Masterclass - Workshop 1: Data Enrichment using Clearbit
PPTX
How to Call Python Function from Menu Item
PPTX
How to make a field widget in odoo 17 - Odoo Slides
PPTX
How to Create and Manage Wizard in Odoo 17
PPTX
How to Customize POS Receipts in the Odoo 17
PPTX
How to Empty a One2Many Field in Odoo 17
PPTX
How to Add Barcode on PDF Report in Odoo 17
PPTX
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
PPTX
How to Empty a Many2Many Field in Odoo 17
PDF
Dynamics AX Fast Sales Quotation
PPTX
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
PPTX
How to Modify Existing Web Pages in Odoo 18
PDF
Salesforce crm projects
PPTX
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
PPTX
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
PPTX
Point of Sale.pptx
PDF
Intalio Project Dogfood And Doubleshot
PPTX
How to Create a Dynamic Snippet in Odoo 17
PPTX
Dolibarr - what's new in 10.0 - devcamp lyon 2019
PDF
Oracle 11i forms personalization
Customer Automation Masterclass - Workshop 1: Data Enrichment using Clearbit
How to Call Python Function from Menu Item
How to make a field widget in odoo 17 - Odoo Slides
How to Create and Manage Wizard in Odoo 17
How to Customize POS Receipts in the Odoo 17
How to Empty a One2Many Field in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Empty a Many2Many Field in Odoo 17
Dynamics AX Fast Sales Quotation
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
How to Modify Existing Web Pages in Odoo 18
Salesforce crm projects
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
Point of Sale.pptx
Intalio Project Dogfood And Doubleshot
How to Create a Dynamic Snippet in Odoo 17
Dolibarr - what's new in 10.0 - devcamp lyon 2019
Oracle 11i forms personalization
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
master seminar digital applications in india
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
GDM (1) (1).pptx small presentation for students
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharma ospi slides which help in ospi learning
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
master seminar digital applications in india
O5-L3 Freight Transport Ops (International) V1.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A systematic review of self-coping strategies used by university students to ...
Supply Chain Operations Speaking Notes -ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Anesthesia in Laparoscopic Surgery in India
Module 4: Burden of Disease Tutorial Slides S2 2025
GDM (1) (1).pptx small presentation for students
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3

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

  • 1. How to Add Button in Chatter in Odoo 18 Enterprise
  • 2. Enterprise Improving user experience in Odoo often involves customizing the chatter, a central hub for communication and updates on specific records. Adding custom buttons can streamline operations, enabling users to trigger workflows or generate reports directly. This guide outlines the steps to add a button to the chatter in Odoo 18, providing code snippets to help you customize this functionality for your business needs efficiently. Introduction
  • 3. Enterprise Step 1: Create the Button in the Chatter To introduce a button in the chatter, you'll need to create a new template that extends the existing mail chatter template. Here’s how to do this:
  • 4. Enterprise <?xml version="1.0" encoding="UTF-8"?> <templates> <t t-name="important.Chatter" t-inherit="mail.Chatter" t-inherit-mode="extension"> <xpath expr="//*[contains(@class, 'o-mail-Chatter-activity')]" position="before"> <button class="btn btn-warning text-nowrap me-2" t-att-class="{'my-2': !props.compactHeight }" data-hotkey="shift+i" t-on-click="markAsImportant"> <span>Mark as Important</span> </button> </xpath> </t> </templates>
  • 5. Enterprise This code snippet adds a "Mark as Important" button to the chatter. The XML template extends the existing mail.Chatter, inserting the button in the activity area with a warning color and a keyboard shortcut (Shift+i). When clicked, the button triggers the markAsImportant JavaScript method.
  • 6. Enterprise Step 2: Define the Button's Functionality Next, you need to implement the functionality that occurs when the button is clicked by enhancing the Chatter component with a new method.
  • 7. Enterprise /** @odoo-module **/ import { Chatter } from "@mail/chatter/web_portal/chatter"; import { patch } from "@web/core/utils/patch"; patch(Chatter.prototype, { async markAsImportant() { await this.env.services.action.doActionButton({ type: "object", resModel: this.props.threadModel, resId: this.props.threadId, name: "action_mark_as_important", }); }, });
  • 8. Enterprise This code defines the markAsImportant function that will be triggered when the button is clicked. It utilizes the patch function from Odoo’s core utilities to enhance the existing Chatter functionality, allowing the button to trigger a specific server-side action. The resModel and resId parameters dynamically refer to the current model and record ID, while action_mark_as_important indicates the server-side method to be executed.
  • 9. Enterprise Step 3: Implement the Logic in Your Model Now, define the logic that updates the record when the button is clicked. For this example, we will modify the sale.order model. Add the following code to sale_order.py file.
  • 10. Enterprise from odoo import fields, models class SaleOrder(models.Model): _inherit = 'sale.order' important = fields.Boolean("Important", default=False) def action_mark_as_important(self): """Mark the record as important and post a message in chatter""" for record in self: record.important = True record.message_post( body="This record has been marked as important.") return { 'type': 'ir.actions.client', 'tag': 'reload', }
  • 11. Enterprise In this code, we create a Boolean field named important and define the action_mark_as_important method. This method marks the record as important and posts a message in the chatter.
  • 12. Enterprise Step 4: Add the Field to the View To ensure that the new field appears in the form view, add it to the appropriate view definition. Include the following XML code to add the field in the sale.order form view
  • 13. Enterprise <?xml version="1.0" encoding="UTF-8" ?> <odoo> <record id="sale_order_view_form" model="ir.ui.view"> <field name="name">sale.order.view.form.inherit.chatter.button</field> <field name="model">sale.order</field> <field name="inherit_id" ref="sale.view_order_form"/> <field name="arch" type="xml"> <field name="date_order" position="after"> <field name="important" invisible="1"/> </field> </field> </record> </odoo>
  • 14. Enterprise This code adds the important field to the sale.order form, while keeping it invisible. Step 5: Update the Manifest File Don’t forget to update the __manifest__.py file of your custom module to include the newly created XML and JavaScript files.
  • 17. Enterprise Conclusion By following these steps, you will have successfully added a button to the chatter in Odoo 18. Clicking the "Mark as Important" button updates the important field and posts a message in the chatter. This functionality allows users to trigger specific actions directly from the record's communication hub, enhancing interactions within the platform. Customizing the chatter opens up numerous possibilities for improving user experiences in Odoo.
  • 18. 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