Skip to Content
Menu
This question has been flagged
1 Reply
5659 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.

Avatar
Discard
Best Answer

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']),
    ]

Avatar
Discard