Search code examples
odooodoo-10odoo-11

how to hide field in one2many in odoo


I have fields on one2many tree view (check box which is boolean field and salesperson which is many2one). Now, I want to hide a field in one2many tree view based on a boolean field. when checkbox(which is in one2many field) is true then salesperson(field_name=salesman_id) field is hide(which is also in one2many field).

I used below code but not work.

  <xpath expr="//form[1]/sheet[1]/notebook[1]/page[1]/field[@name='order_line']/tree[1]/field[@name='price_unit']" position="after">
    <field name="salesman_id" attrs="{'invisible':[('checkbox', '=', True)] }"/>
  </xpath>

Please, Find the attachment. enter image description here How to do that. Thanks in advance.


Solution

  • The tree view field invisible attribute will not hide the column of the tree view completely, it will just hide the field value, because others rows could contain values that cause the column to show a value for that row.