Odoo Help

Welcome!

This community 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.

0

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

By
Eric
on 3/24/15, 2:29 PM 844 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.

Example:

     <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

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 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

Eric
on 3/24/15, 3:09 PM

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/24/15, 2:29 PM
Seen: 844 times
Last updated: 3/24/15, 3:09 PM