Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hello everyone! I'm new in OpenERP (just a few days) and I would like to create a simple model with 2 fields: "name" (text) and "age"(integer)
- name - is required and can contain string not longer than 20 symbols - it's easy
- age - is required and should contain integer greater or equal than 20
My question is - how I can verify or check imput values for field "age"?
Thanks a lot!
There are lots of ways you can go for.
- You have to override create and write method and in that method you can check whether value of age is greater than or equal to 20. You may find many examples about how to override create and write methods.
- Best way is to define a custom constraint on that field.
def _check_age(self, cr, uid, ids, context=None): obj = self.browse(cr, uid, ids, context=context) if obj.your_age_field < 20: return False return True _constraints = [(_check_age, 'Age must be greater than or equal to 20.', ['your_age_field']),]
Hope this will help you.
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
|Asked: 9/14/13, 4:52 AM|
|Seen: 845 times|
|Last updated: 3/16/15, 8:10 AM|