Odoo: Conditional invisible attribute on fields only works in one direction?

This works well to me

<record id="custom_product_template_form_view" model="ir.ui.view">
    <field name="name">custom.product.template.form</field>
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_form_view" />
    <field name="arch" type="xml">
        <field name="product_manager"  position="replace">
            <field name="product_manager" attrs="{'invisible': [('sale_ok', '=', True)]}"/>
        </field>
    </field>  
</record>

If you find any problems you can try the "federico" answer just to modify the attrs attribute. My solution may modify or remove other attributes if they already exist in the original form.


Using position="replace" could bring problems, the best option is to use position="attributes"

Imagine that another installed module (named module X) is inheriting the tag you are replacing. When you update your Odoo system, it will crash because the module X cannot find the tag you replaced.

This code works perfectly for me:

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