Odoo Help

0

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

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

Hi, 

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:

    @api.multi
def to_close(self):
for record in self:
if record.reason and record.so_id:
record.write({'state':'close'})
else:
raise ValidationError(_('Missing required values!'))

 
Thanks 


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.

Register

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)

Stats

Asked: 2/16/16, 4:52 AM
Seen: 527 times
Last updated: 2/16/16, 4:52 AM