Odoo Help

1

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

By
Gopalakrishnan Kasilingam
on 12/24/14, 12:57 AM 691 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']),
    ]

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