Creating a Chatter Button in Odoo 16: A Step-by-Step Guide

The Chatter feature serves as a communication tool present on various records within Odoo. For instance, it facilitates emailing customers directly from a sales order or quotation, enabling seamless communication to discuss details further. Employees can interact with each other regarding process issues or updates by logging private notes inaccessible to customers. Moreover, individuals not initially part of a conversation can be invited to join by adding themselves as Followers to the document.

Below outlines the basic procedures for utilizing the chatter feature in Odoo:

Go to the Appropriate Record:

Access your Odoo instance and locate the specific record where you intend to utilize the chatter feature (such as a sales order, purchase order, project task, etc.).

Conversations Tab:

In Odoo, you'll usually find a "Conversations" tab or section within the form view of the record.

Draft a Message:

To publish a message in the conversations section, select the text box labeled "Post message" or a similar option.

Enter your message into the text box. Additionally, you can format your text, attach files, and tag other users using the toolbar options.

Submit the Message:

Once you've composed your message, click the "Publish" button to share it in the conversations section.


Users with access to the record will be able to view the message.

Followers and Alerts:

You have the option to either track or stop tracking a record by selecting the "Follow" or "Unfollow" button in the conversations section.


By following a record, you'll receive notifications in the conversations section whenever updates or new messages pertaining to that record are posted.

Attached Files:

You have the option to append files to messages in the conversations section. Click on the paperclip icon to attach files either from your computer or from the document management system within Odoo 16.


References:

To reference a user or group within a message, input "@" followed by their name, and Odoo will propose relevant users and groups. Choose the desired one from the suggestions.


Integration with Email:

Based on your Odoo setup, chatter messages may also be dispatched as email notifications to applicable users.

Initially, generate an XML file to display the button and input the following code.


<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-inherit="mail.ChatterTopbar" t-inherit-mode="extension">      <xpath expr="//button[hasclass('o_ChatterTopbar_buttonSendMessage')]" position="after">
          <button class="o_ChatterTopbar_button o_ChatterTopbar_buttonUserNote btn text-nowrap"
                  type="button"
                  t-att-class="{
                                'o-active btn-odoo': chatterTopbar.chatter.composerView and chatterTopbar.chatter.composerView.composer.isLog,
                                'btn-light': chatterTopbar.chatter.composerView and !chatterTopbar.chatter.composerView.composer.isLog or !chatterTopbar.chatter.composerView,
                            }"
                  t-att-disabled="!chatterTopbar.chatter.isTemporary and !chatterTopbar.chatter.hasWriteAccess"
                  t-on-click="chatterTopbar.chatter.onClickUserNote"
                  data-hotkey="shift+m"
          >
                            User note
                        </button>
      </xpath>
</t></templates>

Next, create a click function in the JavaScript file to display the window containing user log details.

/** @odoo-module **/
import { registerModel } from '@mail/model/model_core';
import { attr, one } from '@mail/model/model_field';
import { clear, insert, link } from '@mail/model/model_field_command';
import { makeDeferred } from '@mail/utils/deferred';
const getThreadNextTemporaryId = (function () {
let tmpId = 0; return () => {    tmpId -= 1;
    return tmpId;
};})();
const getMessageNextTemporaryId = (function () {
let tmpId = 0; return () => {    tmpId -= 1;
    return tmpId;
};})();
registerModel({
name: 'Chatter', recordMethods: {      onClickLogNote() {
        if (this.composerView && this.composerView.composer.isLog)     {
           this.update({ composerView: clear() });
        } else {
            this.showLogNote();
        }
    },
          showLogNote() {
        this.update({ composerView: {} });
        this.composerView.composer.update({ isLog: true });
        this.focus();
    }, 
});

This approach allows us to incorporate a button within the conversations section.

Managing the Kiosk System in Odoo 17 Point of Sale