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
Ad

More Related Content

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

How to Call Python Function from Menu Item
How to Call Python Function from Menu ItemHow to Call Python Function from Menu Item
How to Call Python Function from Menu Item
Celine George
 
How to make a field widget in odoo 17 - Odoo Slides
How to make a field widget in odoo 17 - Odoo SlidesHow to make a field widget in odoo 17 - Odoo Slides
How to make a field widget in odoo 17 - Odoo Slides
Celine George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
Celine George
 
How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17
Celine George
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
Celine George
 
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Create a Popup in Odoo POS 17 - Odoo 17 SlidesHow to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
Celine George
 
How to Empty a Many2Many Field in Odoo 17
How to Empty a Many2Many Field in Odoo 17How to Empty a Many2Many Field in Odoo 17
How to Empty a Many2Many Field in Odoo 17
Celine George
 
Dynamics AX Fast Sales Quotation
Dynamics AX Fast Sales QuotationDynamics AX Fast Sales Quotation
Dynamics AX Fast Sales Quotation
Julien Lecadou,MSc.
 
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckboxCustom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
JanBogaert8
 
How to Modify Existing Web Pages in Odoo 18
How to Modify Existing Web Pages in Odoo 18How to Modify Existing Web Pages in Odoo 18
How to Modify Existing Web Pages in Odoo 18
Celine George
 
Salesforce crm projects
Salesforce crm projects Salesforce crm projects
Salesforce crm projects
Advanz Knowledge Systems P Ltd
 
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 SlidesHow to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 SlidesHow to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
Celine George
 
Point of Sale.pptx
Point of Sale.pptxPoint of Sale.pptx
Point of Sale.pptx
YagnikPoshiya
 
Intalio Project Dogfood And Doubleshot
Intalio Project Dogfood And DoubleshotIntalio Project Dogfood And Doubleshot
Intalio Project Dogfood And Doubleshot
Tomoaki Sawada
 
How to Create a Dynamic Snippet in Odoo 17
How to Create a Dynamic Snippet in Odoo 17How to Create a Dynamic Snippet in Odoo 17
How to Create a Dynamic Snippet in Odoo 17
Celine George
 
Dolibarr - what's new in 10.0 - devcamp lyon 2019
Dolibarr - what's new in 10.0 - devcamp lyon 2019Dolibarr - what's new in 10.0 - devcamp lyon 2019
Dolibarr - what's new in 10.0 - devcamp lyon 2019
Laurent Destailleur
 
Oracle 11i forms personalization
Oracle 11i forms personalizationOracle 11i forms personalization
Oracle 11i forms personalization
Kaushik Kumar Kuberanathan
 
Apps 11i10 forms_personalization
Apps 11i10 forms_personalizationApps 11i10 forms_personalization
Apps 11i10 forms_personalization
Vinod Reddy
 
How to Call Python Function from Menu Item
How to Call Python Function from Menu ItemHow to Call Python Function from Menu Item
How to Call Python Function from Menu Item
Celine George
 
How to make a field widget in odoo 17 - Odoo Slides
How to make a field widget in odoo 17 - Odoo SlidesHow to make a field widget in odoo 17 - Odoo Slides
How to make a field widget in odoo 17 - Odoo Slides
Celine George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
Celine George
 
How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17How to Customize POS Receipts in the Odoo 17
How to Customize POS Receipts in the Odoo 17
Celine George
 
How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17How to Empty a One2Many Field in Odoo 17
How to Empty a One2Many Field in Odoo 17
Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
Celine George
 
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Create a Popup in Odoo POS 17 - Odoo 17 SlidesHow to Create a Popup in Odoo POS 17 - Odoo 17 Slides
How to Create a Popup in Odoo POS 17 - Odoo 17 Slides
Celine George
 
How to Empty a Many2Many Field in Odoo 17
How to Empty a Many2Many Field in Odoo 17How to Empty a Many2Many Field in Odoo 17
How to Empty a Many2Many Field in Odoo 17
Celine George
 
Dynamics AX Fast Sales Quotation
Dynamics AX Fast Sales QuotationDynamics AX Fast Sales Quotation
Dynamics AX Fast Sales Quotation
Julien Lecadou,MSc.
 
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckboxCustom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
JanBogaert8
 
How to Modify Existing Web Pages in Odoo 18
How to Modify Existing Web Pages in Odoo 18How to Modify Existing Web Pages in Odoo 18
How to Modify Existing Web Pages in Odoo 18
Celine George
 
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 SlidesHow to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
Celine George
 
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 SlidesHow to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
How to Add Button in Chatter in Odoo 17 - Odoo 17 Slides
Celine George
 
Intalio Project Dogfood And Doubleshot
Intalio Project Dogfood And DoubleshotIntalio Project Dogfood And Doubleshot
Intalio Project Dogfood And Doubleshot
Tomoaki Sawada
 
How to Create a Dynamic Snippet in Odoo 17
How to Create a Dynamic Snippet in Odoo 17How to Create a Dynamic Snippet in Odoo 17
How to Create a Dynamic Snippet in Odoo 17
Celine George
 
Dolibarr - what's new in 10.0 - devcamp lyon 2019
Dolibarr - what's new in 10.0 - devcamp lyon 2019Dolibarr - what's new in 10.0 - devcamp lyon 2019
Dolibarr - what's new in 10.0 - devcamp lyon 2019
Laurent Destailleur
 
Apps 11i10 forms_personalization
Apps 11i10 forms_personalizationApps 11i10 forms_personalization
Apps 11i10 forms_personalization
Vinod Reddy
 

More from Celine George (20)

How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 SalesHow to Manage Cross Selling in Odoo 18 Sales
How to Manage Cross Selling in Odoo 18 Sales
Celine George
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 InventoryHow to Manage Manual Reordering Rule in Odoo 18 Inventory
How to Manage Manual Reordering Rule in Odoo 18 Inventory
Celine George
 
How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18How to Use Upgrade Code Command in Odoo 18
How to Use Upgrade Code Command in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
How to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 SalesHow to Manage Upselling in Odoo 18 Sales
How to Manage Upselling in Odoo 18 Sales
Celine George
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18How to Create A Todo List In Todo of Odoo 18
How to Create A Todo List In Todo of Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Ad

Recently uploaded (20)

Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
Ad

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
  翻译: