2
votes

I have try to hide discount field in invoice form by xpath. However it doesn't work.

The following is my code :

<odoo>
  <data>
    <record model="ir.ui.view" id="hidden_discount">
      <field name="name">account.invoice.hidden.discount</field>
      <field name="model">account.invoice</field>
      <field name="inherit_id" ref="account.invoice_form"/>
      <field name="arch" type="xml">
        <xpath expr="//field[@name='discount']" position="attributes">
            <attribute name="invisible">True</attribute>
        </xpath>
      </field>
    </record>
  </data>
</odoo>

Do you have any solution or suggestion?

1

1 Answers

1
votes

There is no direct form view design for One2many field. So we need to upgrade account.invoice.line form view directly.

Try with following code.

<record model="ir.ui.view" id="hidden_discount">
    <field name="name">account.invoice.line.hidden.discount</field>
    <field name="model">account.invoice.line</field>
    <field name="inherit_id" ref="account.view_invoice_line_form"/>
    <field name="arch" type="xml">
        <field name="discount" position="attributes">
            <attribute name="invisible">1</attribute>
        </field>
    </field>
</record>