Odoo Help


How to set readonly based on a many2one fields value with domain?

on 3/24/15, 2:29 PM 1,798 views

Hello, I am trying to set a readonly attribute to True or False for a field on an xml view if a many2one field has a certain value for that record using the domain.


     <field name='some_field' attrs=" { 'readonly': [('product_id.active', '=', False )] }" />

The problem is I get an error saying:

     Error: Unknown field product_id.active in domain [["product_id.active","=",False]]  

Is there a way to find what the related value is for a many2one field, and set another fields attributes based on that? Thank you


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 3/24/15, 2:48 PM

You can create a related ...

rel_prod_active = field.related('product_id','active', string="is_prod_active', type='boolean') and use in domain this related field: [["rel_prod_active","=",False]] ...

Not tested... but it should works !

Thank you for your post. I was able to get this to work, but was trying to avoid creating another field on the model. Nonetheless, I will use this because it is easy to implement. Thank you

on 3/24/15, 3:09 PM

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: 3/24/15, 2:29 PM
Seen: 1798 times
Last updated: 3/24/15, 3:09 PM