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

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

By
Anabela Damas
on 2/16/16, 4:52 AM 347 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 


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