0
votes

I want to Make a field visible/invisible based on the value of many2one field, for example if I got two values ("Test " and "Other") in a many2one field , now when I select value "Test" from many2one field it will show a field , else it will stay invisible . My question is how I can put attrs or domain filter on that field to be visible or invisible based on the value coming from a many2one field.How I can do it?
Please help . thanks in advance

2

2 Answers

1
votes

Note : It is not a good approach to hide fields based on value of many2one field because if someone change value from front end this trick will not work any more.

but to achieve this you can do

<field name="field_you_want_make_invisible" attrs="{'invisible':[('m2o_field','=','Test')]}"/>
1
votes

Try to do it in the xml, its better if you show me the code:

<field name="property_account_position" position="attributes">
    <attribute name = "attrs">{'invisible':[('customer','=',True)]}</attribute>
</field>

Here, the field property_account_position will be invisible if the user is a customer.