Odoo Help


Field limitation/filtering in model

on 9/14/13, 4:52 AM 903 views

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!


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 9/14/13, 5:55 PM

There are lots of ways you can go for.

  1. 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.
  2. Best way is to define a custom constraint on that field.

For ex:

def _check_age(self,  cr,  uid, ids, context=None):
    obj = self.browse(cr, uid, ids[0], 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.

Thanks! Now I understend better how openerp works!

on 9/14/13, 8:11 PM

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

0 follower(s)


Asked: 9/14/13, 4:52 AM
Seen: 903 times
Last updated: 3/16/15, 8:10 AM