Odoo Help


Required by state, using the states argument in the field ?

Anabela Damas
on 2/16/16, 4:52 AM 928 views


In early versions I used to do this:

states={'close': [('required', True), ('readonly',True)]}

in the definition of the field. When I did this it prevent to change the state while the field (the one required in the next state) isn't set.

In odoo 9 the state changes anyway and then if you try to edit the record you see that the fields is required. 

So, my question is how do I declare my filed in order to prevente any changes of state if the field is not set? 

For now, I did this:

def to_close(self):
for record in self:
if record.reason and record.so_id:
raise ValidationError(_('Missing required values!'))


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/16/16, 4:52 AM
Seen: 928 times
Last updated: 2/16/16, 4:52 AM