VígJAni
VígJAni

Reputation: 303

Odoo. I'd like to make invisible the record in tree view, depending value of one field

Openerp, Odoo question. I'd like to hide the row in tree view depending one field (e.g. item is not in stock).

Maybe I need to put this somewhere in tree_view.xml:

attrs="{'invisible': [('in_stock','=', 0)]}"

It would be fine, if this works, like the res_partner 'Active' flag When 'Active' field is False, all record is disappeared.

Any advice would be appreciated!

Upvotes: 2

Views: 2407

Answers (2)

Hilar AK
Hilar AK

Reputation: 1675

You can hide using the following syntax:

<field name="flag" invisible="1"/>
<field name="x" attrs="{'invisible': [('flag','=', False)]}"/>

Here flag should be a computed field which computes the stock of current item. so in script just make the field as:

flag = fields.Boolean("String", compute="get_stock_status")

def get_stock_status(self):
    # do your computation and change values of flag accordingly
    self.flag = False

Upvotes: 1

Charif DZ
Charif DZ

Reputation: 14721

If you want to hide the record completely than use this domain in the window action. To show only the records that matches the domain.

       <field name="domain">[('in_stock', '=', 0)]</field>

Upvotes: 1

Related Questions