Breaking News
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.




0 comments:

Post a Comment

 
Toggle Footer