AmiNe AmiNe - 2 months ago 36
Python Question

Hide some lines in odoo treeview

I am trying to hide some lines in a tree view according to a specific flag, here is my tree view's xml code :

<record model='ir.ui.view' id='my_object_tree'>
<field name="name">my_object.tree</field>
<field name="model">my_object</field>
<field name="arch" type="xml" >
<tree string="title" attrs="{'invisible': [('my_flag','=',False)]}">
<field name="name"/>
<field name="my_flag"/>

but it seems that "invisible" doesn't work here,
I can hide all fields but I in that case empty lines will appear in the tree view.
Is there any other solution please?


What objects appear in a list view is determined by a domain that is a part of the action definition:

<record model="ir.actions.act_window" id="my_object_action">
    <field name="name">my_object.action</field>
    <field name="res_model">my_object</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[
        ('my_flag', '=', True)