Reputation: 1318
I have a tree view in which I want to display a column depending on the value of another field. To be specific, in the Inventory
app, I want to add a column in the tree view when the picking type is 'Internal Transfers'. I do not want to show the same column in any other picking type.
Please note, I am customizing this in Odoo Enterprise Edition.
I did attrs="{'invisible': [('x_picking_type_name','=', 'Internal Transfers')]}"
, where x_picking_type_name
is a custom field in the model. I am able to hide values in the records but the column remains in other picking types.
I suppose, there is a way around with context but I could not make it work. I will appreciate any help on this.
The XML I am using. I am trying it in original view without inheriting.
<?xml version="1.0"?>
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" decoration-danger="state not in ('cancel', 'done') and min_date < current_date" string="Picking list">
<field name="name"/>
<field name="location_dest_id"/>
<field name="partner_id"/>
<field name="date" invisible="1"/>
<field name="min_date"/>
<field name="origin"/>
<field name="x_picking_type_name"/>
<field name="check_todo" attrs="{'invisible': [('x_picking_type_name','!=', 'Internal Transfers')]}"/>
<field name="group_id" invisible="1"/>
<field name="backorder_id"/>
<field name="state"/>
<field name="priority" invisible="1"/>
<field name="picking_type_id" invisible="1"/>
<field name="product_id"/>
</tree>
Upvotes: 2
Views: 1393
Reputation: 51
According to this post https://www.odoo.com/es_ES/forum/ayuda-1/how-to-add-a-field-conditional-to-tree-view-of-customer-14707#answer_198626
`attrs="{'invisible':[('customer','!=',True)]}"`
Upvotes: 0