Odoo Help

3 Answers
joseph d'souza
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 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>

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>

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

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

Vinod Kumar
3/2/16, 1:10 AM

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

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.

Ask a Question
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now