Hello Odoo Developers, Here in this article we will discuss adding chatter in form view in odoo 17. In Odoo 17, the Chatter functionality works with users within records. Using chatter, you can write internal notes, chat with colleagues, customers, and partners, and track changes for a particular record. This chatter functionality enhances both internal and external communications and operations. Chatter stores all communication history, activities, and modifications, which are displayed inside the chatter. Now you might be curious about how you can add this chatter functionality in any odoo module. So here in this article, we will discuss how to add chatter in form view in odoo 17.
Table of Contents
Add Chatter in Form View in Odoo 17
Chatter appears at the right side of the form view of models or the bottom side of the form view, depending on the position attribute.
To interact with chatter with the form view, we have to create a custom model that doesn’t have a chatter view yet.
Let’s see how to add chatter in form view.
The current form view XML looks like this as follow:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="demo_view_form" model="ir.ui.view">
<field name="name">demo.demo.view.form</field>
<field name="model">demo.demo.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>
XMLTo add a chatter view inside the form view, the first and most important step is to inherit the ‘mail.thread’ model in our custom model code. Additionally, we must add a list of dependencies to the manifest file.
from odoo import fields, models
class Demo(models.Model):
_name = 'demo.demo'
_description = 'Demo'
_inherit = 'mail.thread'
name = fields.Char(string='Reference')
partner_id = fields.Many2one('res.partner', string='Customer')
date = fields.Date(string='Date')
status = fields.Selection([('draft', 'Draft'), ('qualified', 'Qualified')],
default='draft')
company_id = fields.Many2one('res.company',
default=lambda self: self.env.company)
PythonNext, add this class oe_chatter and fields of chatter in XML like this in my above given XML code:
<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>
Add Chatter in Form View in Odoo 17Now, upgrade the module, you will able to see the newly added chatter in the form view. Chatter provides options to send messages, mail, and also long notes, add attachments, and view followers. You can also follow the records by clicking on the follow button.
It is possible to change and remove the log notes from the lines. You can also respond with emojis, edit, and add to favorites.
Tracking Fields Changes
In Odoo, multiple users can access the same record, making it crucial to monitor changes made to fields. Odoo offers tracking of field values, and whenever a change occurs, chatter will be notified.
For Example:
stage = fields.Selection([('draft', 'Draft'),
('qualified', 'Qualified')],
default='draft', tracking=True)
PythonIf there is a any changes in this record stage, it will be added as a log in the chatter.
Schedule Activities from the Chatter
On the basis of the discussion, we can also plan activities. This requires that our custom model inherit the mail.activity.mixin model.
class TravelManagement(models.Model):
_name = 'travel.management'
_description = 'Travel Management'
_inherit = ['mail.thread', 'mail.activity.mixin']
PythonAfter adding this, 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>
XMLThe Activities button has been added to the Chatter after the module has been upgraded. This website allows you to create, mark as finished, modify, and cancel activities instantly.
Similarly, to improve traceability and communication, Chatter can be added to any form view.
Related Post:
>> Odoo.sh VS Odoo Online VS Odoo On-Premises
>> What is Odoo ERP? 11 Reasons Why You Should Use Odoo?
Conclusion for Add Chatter in Form View in Odoo 17
Integrating Chatter into the form view of Odoo 17 significantly enhances communication, collaboration, and traceability within your business processes. By following the steps outlined, you can easily Add Chatter in Form View in Odoo 17 for any custom module, enabling users to track activities, view logs, and manage records seamlessly.
Chatter not only keeps a history of interactions but also supports activity scheduling, making it an essential feature for effective record management and real-time updates. This guide demonstrates how Chatter integration can streamline workflow, ensuring that all stakeholders are informed and engaged in every stage of the record lifecycle.
Thank You.