Odoo Help


How to make a field invisible using compute field based on a condition?

on 2/25/16, 4:10 AM 4,062 views


Is it possible to use a computed field to make a particular field invisible based on a condition?

is it possible using compute field?
If the answer is yes, how can this effect be visible in the view?

Please help me


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/25/16, 5:23 AM


You could use it like a normal field, for example:

<field name="make_invisible" invisible="1"/>
<field name="field_x" attrs="{'invisible':[('make_invisible', '=', True)]}"/>

Just note that the fields functions just compute it's value when the form is saved. You could assign a default_value for the function field or change it's value using an onchange.

Hi Axel Mendoza i need invisible the filed through python code only for field level security my issue like this: . When we want to invisible a field conditionally in same group, we using domains to “attrs”. Using browser inspect element feature we can simply remove “oe_invisible” css class and remove the invisible logic.

on 2/25/16, 6:41 AM

then change the view by override of the method fields_view_get and deal with xml nodes

Axel Mendoza
on 2/26/16, 9:18 PM

Akhil P Sivan

--Akhil P Sivan--

| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/25/16, 6:47 AM


I think you may use a compute boolean field, that becomes true or false based on the condition. You can make another field visible or invisible using the "attrs" attribute, based on that boolean field. You may note that onchange is default on compute fields and it also compute the values, when you open or edit in form view.

For example, you may see the following example, in that, if the value of field1 is "Any_String", the field2 will be invisible.

in .py file:

class test_model(models.Model):

_name = "test.model"

field1 = fields.Many2one('another.model', String="First field")

check = fields.Boolean(compute='_get_value')

field2 = fields.Char(String="Second field")



def _get_value(self):

if self.field1.name == "Any_String":

self.check = True


self.check = False

in xml file:

    <record model="ir.ui.view" id="test_model_form_view">

<field name="name">test.model.form.view</field>

<field name="model">test.model</field>

<field name="arch" type="xml">


                    <field name="field1" />

                    <field name="check" invisible="1" />

                    <field name="field2" attrs="{'invisible':[('check', '=', True)]}"



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: 2/25/16, 4:10 AM
Seen: 4062 times
Last updated: 11/20/17, 6:24 PM