Odoo Help


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.


[v7] Change if the field is required dynamically

on 3/30/15, 6:13 PM 997 views

Is there a way to change whether the field is required or not based on some method or some other field in a different module?

Something that would work both on create and write?


Brett Lehrer

--Brett Lehrer--
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 4/17/15, 12:13 AM

Create a related field and hide it in the form view, then write it into the attrs attribute of the view definition:

class my_model(osv.osv):
    _name = 'my.model'
    _columns = {
        # ...
        'other_field': fields.related('other_object_id', 'other_object_field', type='boolean', string='Other Field'),
<field name="my_field" attrs="{'required': [('other_field','=',True)]}"/>
<field name="other_field" invisible="1"/>

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)


Asked: 3/30/15, 6:13 PM
Seen: 997 times
Last updated: 8/27/15, 8:32 AM