There are fields like campaign_id
which i would like to hide, or append some other fields after them:
But all my expression get fully ignored:
like...
<xpath expr="//field[@name='campaign_id']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
...or...
<field name="campaign_id" invisible="1" />
Other expressions in the same xml file will be correctly evaluated.
There are no errors printed or shown.
This is the inherid_id
and more:
<odoo>
<record id="crm_lead_view_form" model="ir.ui.view">
<field name="name">crm.lead.inherit.view.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
Dont know if it's related: It seems that the campaign_id
field is an merged field from crm_lead.py
.
Maybe someone can lift the (for me) unknown 'magic' which prevents edit / hide / append after / ... the merged field campaign_id
?
Odoo has one formular view for leads and opportunities. Lots of fields are defined twice in the view, that's why your code is working without errors. But using XPath (your first approach) or changing something by node names (your second approach) only changes the "first" found target. And the first found target is for the "lead's view".
You can see it here
A simplified example:
<page name="extra" string="Extra Info" attrs="{'invisible': [('type', '=', 'opportunity')]}">
<group>
<group string="Tracking" name="categorization">
<field name="campaign_id" />
<field name="medium_id"/>
<field name="source_id"/>
</group>
</group>
</page>
<page name="lead" string="Extra Information" attrs="{'invisible': [('type', '=', 'lead')]}">
<group>
<group string="Marketing">
<field name="campaign_id" />
<field name="medium_id" />
<field name="source_id" />
</group>
</group>
</page>
So if you want to hide one or both fields, you have to use XPath twice or you could also mix it up. But i would prefer using XPath twice, because it's more comprehensible.
<xpath expr="//page[@name='extra']//field[@name='campaign_id']" position="attributes">...</xpath>
<xpath expr="//page[@name='lead']//field[@name='campaign_id']" position="attributes">...</xpath>