2
votes

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!

2

2 Answers

1
votes

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>
1
votes

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