Message Subtypes in Odoo

Message Subtypes in Odoo

Most of the time in Odoo multiple users work on one particular record or document like sale order, Invoice, Tasks etc. In such scenarios, it becomes extremely important to track changes done by every individual against that document. It helps management to find any possible reason in the case of any issue occurs. Odoo provides this feature to great extent with the help of OpenChatter Integration.

Let us consider a scenario where multiple users are working on a single project.Various parameters for that project are already configured like a deadline, Initially Planned Hours etc. Now one of the user changes the value of Planned Hours.So now it is important to know which user has changed it and what was the previous value. We can track it by creating message subtypes in Odoo as following.

It needs to be defined in XML which will have the following syntax.

<record id=”mt_task_planned_hours” model=”mail.message.subtype”>
<field name=”name”>Task planned hours changed</field>
<field name=”res_model”>project.task</field>
<field name=”default” eval=”True”/>
<field name=”description”>Task planned hours changed</field>

Users can also have a mail.message.subtype that depends on an other to act through a related field. For the planned hours, we can have following sysntax for it.

<record id=”mt_task_planned_hours_change” model=”mail.message.subtype”>
<field name=”name”>Task planned hours changed</field>
<field name=”sequence”>10</field>
<field name=”res_model”>project.task</field>
<field name=”parent_id” eval=”ref(‘mt_task_planned_hours’)”/>
<field name=”relation_field”>project_id</field>

Odoo does provide a feature to track various events related to one particular document with the help of _track attribute. If we inherit mail.thread object then with the help of _track attribute, the user can sent notification also to keep aware others about changes happening against this particular document. The syntax can be as follow.

_track = {
‘planned_hours’: {
‘module_name.mt_task_planned_hours’: lambda self, cr, uid, obj, ctx=None: obj.planned_hours,

In order to track changes related to any field, Odoo provides an attribute named as track_visibility.It has to be defined at field level which has below syntax.

planned_hours = fields.Float(string = ‘Initially Planned Hours’, track_visibility=’onchange’, help=’Estimated time to do the task, it is project manager when the task is in draft state.’)

Hence, it is easy to track the changes done so far against any particular document by different users.