Hi there,
I got the same problems, the facts are :
1 -
Code:
<field name="prenom" attrs="{'invisible': [('nom', '=', 'amine') ] }" />
('nom' is a field definition, not a string) doesn't work! Tip to make it work consist to embed it in a <group> tag, eg:
Code:
<group attrs="{'invisible': [('nom', '=', 'amine') ] }"><field name="prenom" /></group>
. note that the group tag is not labelled (no 'string' attribute), so visually not different from a naked <field/> tag.
But that trick simply not working on a tree view: the "group" tag inside a tree view make the field to be always hidden.
2- using
Code:
<field name="prenom" invisible=" 'nom' == 'amine' " />
is perfectly working but useless, since 'nom' here is considered as a string, not a field content. doing
Code:
<field name="prenom" invisible=" nom == 'amine' " />
is more pythonic, but raises an error:
'nom' is not defined!. the attributes cannot access the field content like in point 1!. The "product" module is using that kind of construction in "product_view.xml":
Code:
<field invisible="'partner_id' not in context" name="price"/>
. it seems to work! but it uses the context dictionnary. good luck to understand that code, since there's no piece of documentation about the context dictionnary, and openerp make a heavily use of the context.
it's really frustrating, testing each combinaison is time consumming, and some documentation about the context dictionnary would be really welcome.