Can you describe how track_visibility
works and provide scenario where it is used.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi,
"track_visibility" is used to record each and every action or updates of the particular field.
For example:
'user_id': fields.many2one('res.users', 'Salesperson', readonly=True, track_visibility='onchange', states={'draft':[('readonly',False)]}),
If you want to record a log with your own message use the below function.
Yes let say one scenario like you want to track the visibility of invoice related for ex : invoice is created , invoice is validated, invoice is paid etc..
You can set a mail.message.subtype that depends on an other to act through a relation field. Here is an Account-related subtypes for track visiblity
<record id="mt_invoice_validated" model="mail.message.subtype">
<field name="name">Validated</field>
<field name="res_model">account.invoice</field>
<field name="default" eval="False"/>
<field name="description">Invoice validated</field>
</record>
<record id="mt_invoice_paid" model="mail.message.subtype">
<field name="name">Paid</field>
<field name="res_model">account.invoice</field>
<field name="default" eval="False"/>
<field name="description">Invoice paid</field>
</record>
Your object need to inherit from mail.thread. for traking the visiblity which produces the messages
If an object is inherited from 'mail.thread' then _track is used to send notifications. Therefore 'module.subtype_xml' is the related "Message Subtype". These subtypes have to be declared in XML. Here is an example:
<record id="subtype_xml" model="mail.message.subtype"> <field name="name">Relevant Fields</field> <field name="res_model">account.invoice</field> <field name="default" eval="True"/> <field name="description">some descriotion.</field> </record>
thanks but I need to understand how track_visibility is used in py file
'user_id': fields.many2one('res.users', 'Salesperson', readonly=True, track_visibility='onchange', states={'draft':[('readonly',False)]}),
its available in account_invoice.py
Hello friend can i get automatically created message id i want to change that message
Hi,
Tracking will help users to get the historical data of a field or state of the record. Normally this tracking is recorded in the chatter of the view.
For adding chatter section for a view in Odoo, see: https://www.youtube.com/watch?v=i0KgosdMxIE
To enable tracking of the fields, see: How To Add Field Tracking in Odoo
Thanks
Hi,
Track visibility is used to track the changes made to the fields, as our system is a multi-user system and the different person can access the same record. There might be cases where we have to keep track of who changed the field values. In these cases, we can use track_visibilty.
Refer the section Track visibility in the following blog
https://www.cybrosys.com/blog/how-to-add-chatter-to-form-view-in-odoo-v12
Regards
To understand the logic of track_visibility="onchange" you have to see both the python and xml parts of code.
According to the code you sent track_visibility='onchange' in python means that the field attrs will be re-evaluated whenever any "onchange" function is triggered.
So if we assumed that in view we have
<field name = "nationality" />
<field name = "user_id" attrs="{'invisible': [('nationailty', '=', 'Egyptian')]}" />
The field user_id will only appear if the nationality field (changed) to be Egyptian.
it becomes invisible if nationailty == Egyptian
Track visibility in odoo: https://www.youtube.com/watch?v=7lFvNCIZzkg
Look how to implement Track visibility in Odo: https://learnopenerp.blogspot.com/2022/05/enable-field-tracking-track-visibility-in-odoo-15.html