Enable Dark Mode!
how-to-transfer-chatter-history-from-sales-to-delivery-in-odoo-18.jpg
By: Saneen K

How to Transfer Chatter History from Sales to Delivery in Odoo 18

Sales Odoo 18 Technical

In today’s dynamic business landscape, seamless communication is key to productivity. Odoo addresses this need with Chatter, a built-in feature that provides an integrated, structured way to keep all conversations, notes, and activities tied directly to business documents. From tracking internal notes and logging customer interactions to setting reminders and attaching files, Chatter significantly enhances collaboration across departments. But its power doesn’t stop there.

What happens when a business process spans multiple stages or documents? How can you carry forward important context, such as discussions or decisions made on a Sales Order, into the related Delivery Order or Invoice?

In this blog, we’ll explore how Chatter not only centralizes communication but also helps maintain continuity across the entire workflow in Odoo.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

Key Features of Chatter

1- Send Message

Enables users to send emails directly from the record to all followers. It supports email templates, and any customer replies are automatically logged in the Chatter thread, ensuring no message is lost.

2- Log Note

Allows users to leave internal notes visible only to team members. This is perfect for documenting internal updates, decisions, or instructions without notifying external stakeholders.

3- Schedule Activity

Let's you assign tasks, set deadlines, and schedule follow-ups. Activities appear in both the Chatter and the user’s activity dashboard, keeping everyone on track.

4- Attachments

Easily upload and access files related to a specific record. The attachment count is visible, ensuring documents like invoices, contracts, or reference files are always at hand.

5- Follow / Following Toggle

Allows users to follow or unfollow a document. Following a record ensures that users receive updates and notifications about any changes or messages posted.

6- Followers Management

Displays all current followers of the document. You can add or remove followers manually and even define what types of messages they receive (e.g., activities, notes, emails).

Transferring Chatter History Between Models

In many Odoo 18 implementations, sales and logistics teams work closely together to fulfill customer expectations. Consider a scenario where a Sales Order contains critical customer feedback, negotiation notes, or team discussions recorded in Chatter. As this Sales Order progresses and results in a Delivery Order, the warehouse team needs full visibility into these communications to avoid errors or missed instructions.

For instance, imagine a customer has requested special packaging or has shared delivery timing constraints all noted within the Sales Order's Chatter. By default, this conversation trail remains confined to the Sales module. To ensure smooth coordination, it's beneficial to replicate or link this chatter history to the resulting Delivery Order, giving the warehouse team real-time context without needing to switch between records.

In this guide, we’ll demonstrate how to implement a custom action button on the Delivery Order that programmatically copies chatter messages from the linked Sales Order. This approach can also be adapted into automated server actions or custom workflow logic, depending on business needs.

Step 1: Create a Button in the Sale Form View

Add a button in the sales form view to trigger the action of copying the chatter history from the sales to the delivery.

<record id="view_order_form_inherit_chatter_copy_in_sale" model="ir.ui.view">
   <field name="name">sale.order.form.inherit.copy.chatter.sale</field>
   <field name="model">sale.order</field>
   <field name="inherit_id" ref="sale.view_order_form"/>
   <field name="arch" type="xml">
       <xpath expr="//button[@name='action_draft']" position="after">
           <button name="action_chatter_copy"
                   string="Copy Chatter" class="btn-primary"
                   type="object"/>
       </xpath>
   </field>
</record>

It results, a button ‘Copy Chatter’ appeared near to the cancel button of the sales form view.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

Step 2: Add the Button Action in Python

The following Python code will execute the Chatter history transfer when the button is clicked:

def action_chatter_copy(self):
   """
   Copies Chatter messages from the sale order to the first
   non-cancelled delivery order.
   """
   messages_sale = self.env["mail.message"].search(
       ["&", ("res_id", "=", self.id),
        ("model", "=", "sale.order")], order='create_date asc')
   for chat in messages_sale:
       delivery_id = [x.id for x in
                      self.picking_ids.filtered(
                          lambda l: l.state != 'cancel')]
       chat.copy({"model": "stock.picking", "res_id": delivery_id[0]})

Click on the ‘Copy Chatter’ button, then the chatter history from sales will be copied to the corresponding delivery form view.

Chatter in the sales is given as follows.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

The chatter history from the sales can be visible in the corresponding delivery form view.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

Configuring Custom Copy Logic

While the current implementation transfers the entire chatter history from the Sales Order to the Delivery Order, there may be scenarios where only certain message types, such as internal notes or customer-facing communications, should be copied. This allows for more relevant and streamlined messaging in the Delivery Order.

To accomplish this, change the Python code to filter the messages before copying them. For example, if you only want to put the activity log notes into the Delivery module, you can edit the Python code as follows:

def action_chatter_copy(self):
   """Copies Chatter messages of subtype 'Activities' from the Sales Order to the first non-canceled Delivery Order.
       The method retrieves and copies messages from the Sales Order to the associated Delivery Order (`stock.picking`).
       Only messages of subtype 'Activities' are transferred.
   """
   messages_sale = self.env["mail.message"].search(
       ["&", ("res_id", "=", self.id), ("model", "=", "sale.order")],
       order='create_date asc')
   delivery_id = [x.id for x in
                  self.picking_ids.filtered(lambda l: l.state != 'cancel')]
   for chat in messages_sale.filtered(
           lambda m: m.subtype_id.name == 'Note'):
       chat.copy({"model": "stock.picking", "res_id": delivery_id[0]})

The .filtered() method is used to extract only those messages that meet a specific condition — in this case, messages categorized as “Log Note”.

This approach ensures that only relevant log notes are copied to the Delivery Order, helping maintain a clean, concise, and context-aware communication history.

The image below showcases an example of log note messages recorded in the Sales module.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

The transferred activity log note, now visible in the Delivery Order, is shown below.

How to Transfer Chatter History from Sales to Delivery in Odoo 18-cybrosys

This customization enables you to tailor the Chatter history transfer process according to your specific business requirements.

By copying Chatter history from Sales Orders to Delivery Orders, you can streamline communication and maintain context throughout your workflow. Implementing the steps outlined above allows you to replicate this functionality in your Odoo 18 environment while adapting it to suit your operational needs.

To read more about How to Transfer Chatter History from Sales to Delivery in Odoo 17, refer to our blog How to Transfer Chatter History from Sales to Delivery in Odoo 17.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message