Odoo Help


Hide tree view column using a context value (odoo9)

Adnier Rosello
on 11/1/16, 5:26 PM 260 views


I know that is not possible hide a field in tree view with attrs={"invisible":[('field_name','=',True)]}, and it is possible using: invisible attribute like this: invisible="context.get('field_name',False)", but I want to know how I can pass a field value through context from model to view, Ex:


admin_user = fields.Boolean(string="Name", default=True)



    < field name="field_name" invisible="context.get('admin_user',False)"/>


Any example for this question?,



Nilmar Shereef

--Nilmar Shereef--
| 4 4 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 11/2/16, 6:08 AM

You can hide your field according to your conditions via following steps.
Note : You want to import

from lxml import etree

 In your Python code:

in your xml add invisible=0 with your field in xml:


    < field name="field_name" invisible="0"/>   


I think it may hep you

On 11/2/16, 10:43 AM


you can update the context by calling super of fields_get function from the model of tree view.Can update context by 

context.update({'admin_user':False}) and pass the updated context in super

Hi sarga,

maybe do you have any example by this way, because I don't know how to use this function (fields_get), Thanks.

Adnier Rosello
on 11/10/16, 1:41 PM


I just show you how I just used fields_get in sale order model to update context.

def fields_get(self,cr,user,all fields=None,context=None,write_access=True,attributes=None):



return super(so,self).fields_get(cr,user,allfields,context_copy, write_access,attributes)

on 11/11/16, 10:41 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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: 11/1/16, 5:26 PM
Seen: 260 times
Last updated: 11/2/16, 10:43 AM