Kenly
Kenly

Reputation: 26768

Hide field in one2many_field

I have one2many field with one2many_list tag, and I want to hide qty field which is not needed if I choose for example service.

I have this code in my view:

<field name='type'/>

<field name="products" nolabel="1" widget="one2many_list">
    <tree editable="bottom" >
        <field name='description'/>
        <field name='qty'/>
        <field name='total'/>
    </tree>
</field>

How can i do that using type field?

Upvotes: 0

Views: 146

Answers (1)

JordyRitzen
JordyRitzen

Reputation: 702

You probably want to use the attr tag.

attrs="{'invisible': [('type','=','service')]}"

this will hide the field when the chosen type equals service

Since the field isn't on the same model you could create a functional field on the model of the one2many field where you check if you need to hide the qty field or not

Upvotes: 1

Related Questions