Skip to Content
Menu
This question has been flagged
1 Reply
1080 Views

I'd like field A to appear only if field B has a given value

field B doesn't belong to the same model, it belongs to a model connected through a many2one relationship

How do I write the contents of the attrs attribute for field A in the form ?

Until now I used

Avatar
Discard
Author

It works !

Thank you so much !

Best Answer

First, add a related field in a model where you have field A like this

field_b = field.fieldtype(related='many2one_field.field_b')

then you can use attrs to hide field A like this

attrs="{'invisible': [('field_b', '=', False)]}"
Avatar
Discard