In Odoo 17, Chatter facilitates collaboration among users within records. Users can write internal notes, communicate with colleagues and customers, and track changes. This feature enhances both internal and external communications and streamlines operations. All communication history, activities, and modifications are displayed within Chatter.
Chatter is typically present in the form view of models. Chatter appears at the bottom or on the right side of the form view, depending on the Chatter position attribute.
Let's go over integrating Chatter with the form view. I have a custom model that looks like this because I haven't implemented the Chatter view yet:
Let's see how to add Chatter to this form view.
The current form views XML looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="travel_management_view_form" model="ir.ui.view">
<field name="name">travel.management.view.form</field>
<field name="model">travel.management</field>
<field name="arch" type="xml">
<form>
<header>
<field name="status" widget="statusbar"/>
<button string="Confirm" name="action_confirm"
type="object"/>
</header>
<sheet>
<div class="oe_title">
<div>
<label for="name"/>
</div>
<h1 class="mb32">
<field name="name" class="mb16"/>
</h1>
</div>
<group>
<group>
<field name="partner_id"/>
<field name="date"/>
</group>
<group>
<field name="status"/>
<field name="company_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
</odoo>
To add a Chatter view, the first and most important step is to inherit the ‘mail.thread’ model in our custom model. Additionally, we need to add ‘mail’ to the dependencies list in the manifest.
from odoo import fields, models
class TravelManagement(models.Model):
_name = 'travel.management'
_description = 'Travel Management'
_inherit = 'mail.thread'
name = fields.Char(string='Booking Reference')
partner_id = fields.Many2one('res.partner', string='Customer')
date = fields.Date(string='Booking Date')
status = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed')],
default='draft')
company_id = fields.Many2one('res.company',
default=lambda self: self.env.company)
Also, add the class oe_chatter and fields of chatter in XML like this.
<group>
<field name="status"/>
<field name="company_id"/>
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
After upgrading the module, you will be able to see the newly added Chatter in the form view.
Chatter provides options to send messages, add log notes, add attachments, view followers, and follow the record by clicking the follow button.
The log notes are editable and erasable from the lines. Additionally, you can edit, add to favorites, and respond with emojis.
Tracking fields changes
In Odoo, multiple users can access the same record, making it crucial to monitor changes made to fields. Odoo enables tracking of field values, and whenever a change occurs, Chatter will be notified.
For example, I have enabled tracking for the stage field.
status = fields.Selection([('draft', 'Draft'),
('confirmed', 'Confirmed')],
default='draft', tracking=True)
If there is a change in the record status, it will be added as a log. This demonstrates how we can track field changes in a similar manner.
Schedule activities from the chatter
We can also organize activities based on the discussion. We must inherit the mail.activity.mixin model to our custom model in order to do so.
class TravelManagement(models.Model):
_name = 'travel.management'
_description = 'Travel Management'
_inherit = ['mail.thread', 'mail.activity.mixin']
After that, add the activity_ids field to the XML.
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" groups="base.group_user"/>
<field name="activity_ids"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
After upgrading the module, you will see the Activities button added to the Chatter. You can immediately create, mark as completed, alter, and cancel activities from this page.
Similarly, Chatter can be added to any form view to enhance communication and traceability.
To read more about How to Add Chatter to the Form View in Odoo 16, refer to our blog How to Add Chatter to the Form View in Odoo 16.