In this tutorial i will teach you how to add Chatter to a model in odoo either to an exiting or to a new model.
One of the most important reason why you want to add chatter to your module is simply because you want to keep track of activities carried on in a particular section of your module. One beautiful things about Odoo Chatter is, you can actually add people to follow the activity, just like you follow a topic on a forum and you are also notified of a new comment or like.
Everyone that is added as a follower will be notified whenever an action is performed.
So let’s see how you can add this in your code…
Add Chatter to a Model
Adding chatter to an existing model or a new model can be done by the inheritance of mail mixins: mail.thread and mail.activity.mixin, you may also add mail.alias.mixin.
So, whatever module you are working on, always remember to add this line of code to your python file:
_inherit = ['mail.thread', 'mail.activity.mixin']
This takes care of the message_ids and message_follower_ids
Once you are done with the above, you need to add some lines of code to your xml, add the xml code must be inside your form tag but after the sheet closing tag:
</sheet> <div class="oe_chatter"> <field name="message_follower_ids" widget="mail_followers"/> <field name="activity_ids" widget="mail_activity"/> <field name="message_ids" widget="mail_thread"/> </div> </form>
Having done the above, your result should be like this (below) when you save a record or perform an action.
I hope this was resourceful, if you have questions you can comment below, also remember to share.