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:
XML view:
Adding the above code will show the following:
The following image shows the tracking of field Untaxed Amount in sales orders.
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')
Hi. this is a great post..!!
ReplyDeletethis track_visibility can set on order lines product and prices?
Yes, it can be set on product and prices in order lines.
Delete