Wednesday, 18 December 2013

Hide field in tree view based on condition

Hello All,

In tree view we know how to put domain or attrs to visible or invisible any field,

But, if we want to hide particular field in tree view based on type or state means based on any condition , then its hard to hide as we cannot use attrs to hide as attrs hide only value not a field.

So, its need to put some condition like below as its get value from context and check.

invisible="context.get('picking_type', False) in ['in']"



  1. Like to check. How can I do this in Odoo 8 to hide a column based on state?

    I have tried this, but it didn't work. Any idea?

    I have tried this too but it didn't work either

    Any help? Thanks.

    1. The codes seems missing... anyway a repost here

      I have removed left and right angle brackets.

      field name="price_unit" invisible="context.get('state', True) in ['draft']"
      field name=”price_unit” invisible=”context.get(‘state’) == ‘draft’"

  2. Same, not working in odoo8

    1. This comment has been removed by the author.

    2. The context can only be filled with [True / False]
      in xml : "< field name="pct_of_inv" invisible="context.get('is_lines', True)" / > "
      in python :
      if wizard.advance_payment_method == 'pct_lines':
      res['context'] = {'is_lines':False }
      return res

      if wizard.advance_payment_method == 'lines':
      res['context'] = {'is_lines':True}
      return res

  3. in odoo 9 too...