Odoo Help


Remove Column (Not Only Data) In View and Template From Sales Order

Irving Carrion
on 8/2/16, 11:56 AM 416 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 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 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 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 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)]}"/>




Any help would be much appreciated.



Axel Mendoza
On 8/2/16, 11:45 PM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/2/16, 11:56 AM
Seen: 416 times
Last updated: 8/2/16, 11:45 PM