Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

4

what is track_visibility?

By
Atchuthan - Technical Consultant, Sodexis Inc
on 8/13/13, 6:18 AM 8,102 views

Can you describe how track_visibility works and provide scenario where it is used.

3
joseph d'souza
On 8/13/13, 8:57 AM

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

Atchuthan - Technical Consultant, Sodexis Inc
on 8/13/13, 11:13 AM

Hello friend can i get automatically created message id i want to change that message

Vinod Kumar
on 3/2/16, 1:10 AM
0
AlSayedGamal
On 5/23/15, 10:39 PM


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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 8/13/13, 6:18 AM
Seen: 8102 times
Last updated: 4/6/16, 7:38 AM