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.

1

how to Validate the length of integer value given in a field ?

By
Gopalakrishnan Kasilingam
on 12/24/14, 12:57 AM 415 views

i would like to create an integer field which gets the contact number of the customer (Example : 10 digit).. the value enterned in that integer field must be a 10 digit number not more or less than 10digits else it should shown an error message.

3
Anand
On 12/24/14, 1:04 AM

def _check_length(self, cr, uid, ids, context=None):
    for record in self.browse(cr, uid, ids, context=context):
        if len(record.contact)=10:
            return True
    return False

 

  _constraints = [
        (_check_length, 'Length must be equal to 10 digit, ['contact']),
    ]

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: 12/24/14, 12:57 AM
Seen: 415 times
Last updated: 3/16/15, 8:10 AM