Skip to Content
Menu
This question has been flagged
1 Reply
2435 Views

We are trying to remove a custom column from the Order Detail screen based on if it contains data.  We have been able to remove the line item data using attrs but not the column itself.  Below is the view we are trying to modify.

<record model="ir.ui.view" id="myid_view_sale_order_form">

<field name="inherit_id" ref="sale.view_order_form" />

<field name="model">sale.order</field>

<field name="arch" type="xml">

<xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']" position="before">

<field invisible="context.get('show_sale')" class="text-left" name="ram_esc1" attrs="{'invisible': [('ram_esc1', '==', 0)]}"/>

</xpath>

<xpath expr="//field[@name='order_line']/tree/field[@name='ram_esc1']" position="after">

<field invisible="context.get('show_sale')" class="text-left" name="ram_esc2" attrs="{'invisible': [('ram_esc2', '==', 0)]}"/>

</xpath>

<xpath expr="//field[@name='order_line']/tree/field[@name='ram_esc2']" position="after">

<field invisible="context.get('show_sale')" class="text-left" name="ram_esc3" attrs="{'invisible': [('ram_esc2', '==', 0)]}"/>

</xpath>

<xpath expr="//field[@name='order_line']/tree/field[@name='ram_esc3']" position="after">

<field invisible="context.get('show_sale')" class="text-left" name="ram_esc4" attrs="{'invisible': [('ram_esc4', '==', 0)]}"/>

</xpath>

<xpath expr="//field[@name='order_line']/tree/field[@name='ram_esc4']" position="after">

<field invisible="context.get('show_sale')" class="text-left" name="ram_esc5" attrs="{'invisible': [('ram_esc5', '==', 0)]}"/>

</xpath>

</field>

</record>


Any help would be much appreciated.

Thanks,

Irving

Avatar
Discard
Best Answer

The thing is that the way you are doing it it's not correct. You are doing it on the tree field definition attrs and that will cause to display the data or not based on the value of the field and also the domain for attrs it's based on the field value. Try by using directly <field invisible="context.get('show_sale')" without the attrs to hide it if that not work for you then you could think to define hide them using a security group that will cause that the field get removed from the view if you don't have the group assigned

Avatar
Discard