odoo15 how to set optional="hide" by default in field due date and invoice date

314 Views Asked by At

In Invoice tree view , trying to override the attribute optional="show" to "hide" of inherited tree view?

1 i creted new custom module this the new view

 <record id="hide_view_order_form_inherit" model="ir.ui.view">
        <field name="name">account.move.inherit.view</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_out_invoice_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='invoice_date']" position="replace">
              <field name="invoice_date" optional="hide"/>
            </xpath>
        </field>
    </record>

didn't work

1

There are 1 best solutions below

0
PicchiSeba On

You can overwrite the xml attributes instead of replacing the whole field.

Try with the following:

<record id="hide_view_order_form_inherit" model="ir.ui.view">
    <field name="name">account.move.inherit.view</field>
    <field name="model">account.move</field>
    <field name="inherit_id" ref="account.view_out_invoice_tree"/>
    <field name="arch" type="xml">
        <field name="invoice_date" position="attributes">
          <attribute name="optional">hide</attribute>
        </field>
    </field>
</record>

This way you only replace the 'optional' attribute with 'hide'