在 xpath exp odoo 9 中隐藏字段

Hide field in xpath exp odoo 9

隐藏字段的最佳解决方案是什么,例如。 partner_id 在

<xpath expr=".">
        <field name="partner_id" />
</xpath>

这是从视图中隐藏任何字段的最佳方式。

<xpath expr="//field[@name='partner_id']" position="attributes">
    <attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='partner_id']" position="attributes">
       <attribute name="invisible">1</attribute>
</xpath>

您可以实施的另一种方式是

<field name="partner_id" position="replace">
    <field name="partner_id" invisible="1" />
</field>

这只是上述解决方案的替代方案。

根据特定条件立即使字段 不可见只读 等的替代方法。

<xpath expr="//field[@name='partner_id']" position="attributes">
    <attribute name="attrs">{'invisible': [('field_name', 'Operator', Value)], 
                             'readonly': [('field_name', 'Operator', Value)]}
    </attribute>
</xpath>