Recent Updates
Loading...
Saturday 23 April 2016

How to track a field in messages in Odoo

4/23/2016 11:07:00 am
For tracking the state changes, field changes etc for a model in Odoo, the model should inherit 'mail.thread' and in the form view of the model we have to provide the following code after the <sheet> tag.

Python file:
class SaleOrder(models.Models):
    _name = "sale.order"
    _inherit = ['mail.thread', 'ir.needaction_mixin']

XML view:
<div class="oe_chatter">
   <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
   <field name="message_ids" widget="mail_thread"/>
</div>

Adding the above code will show the following:

  • Created by
  • Modified by etc
For tracking a field we have to specify it in the field definition with parameter track_visibility set to 'always' or 'onchange' like the following:


state = fields.Selection([('draft', 'Unconfirmed'), ('open', 'Confirmed')], string='Status', readonly=True, track_visibility='always')
The following image shows the tracking of field Untaxed Amount in sales orders.




2 comments:

  1. Hi. this is a great post..!!
    this track_visibility can set on order lines product and prices?

    ReplyDelete
    Replies
    1. Yes, it can be set on product and prices in order lines.

      Delete

 
Toggle Footer