How To Post A Message To Chatter In Odoo 16

How To Post A Message To Chatter In Odoo 16

1 minute, 53 seconds Read

In Odoo, Chatter is a communication tool that allows users to collaborate and communicate on records, documents, and other items within the Odoo system. The Chatter feature is available in many Odoo modules, such as Sales, Projects, Tasks, Invoicing, and more.

Chatter in Odoo provides a convenient way for teams to collaborate, share information, and stay up-to-date on the latest developments.

How To Post A Message To Chatter In Odoo 16-cybrosys

Here in this example, In the chatter, it shows the purchase order is created. The changes in the states will be shown here. Initially, the user Mitchell admin changed the purchase order from RFQ state to Purchase order. This helps to show internal communication with users.

In Odoo, these messages are posted on the chat using a message_post () function, which is used to create a new message or reply to an existing message in a record’s chatter.

Here in this blog, we will detail how to post a message to chatter

class School(models.Model):
   _name = 'school.student'
   _description = 'Student'
   _inherit = ['mail.thread','mail.activity.mixin']
   name = fields.Many2one('res.partner', string='Student',help='Name of the Student')
   def action_confirm(self):
       for rec in self:
           rec.state = 'confirm'
           body = _('The %s Student Admission is Confirmed', self.name.name)
           rec.message_post(body=body)

Inside a custom model ‘school.student’, we added message_post() method inside a confirm function. When the student record is confirmed, it shows a message in the chatter as the Student Admission is Confirmed

In the message_post method, content is passed inside the parameter body. In the body, the message that needs to be displayed on the chatter is updated.

How To Post A Message To Chatter In Odoo 16-cybrosys

If the student record state is moved to the confirmed stage, then a message will be shown on the chatter.

This method is also used to add messages to different types of records like contacts, opportunities, sales orders, invoices, and more. The method takes in several arguments, including res_id, model, body, subject, message_type, and subtype_xml_id.

Also, we can pass attachments in the chatter along with messages, which can be done using the following code.

rec.message_post(attachment_ids=[attachment.id])

Attachment records of the ir.attachment model can be passed along with attachment_ids.

So, this is how we can post a message to chatter in odoo 16.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *