콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
5741 화면

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.

아바타
취소
베스트 답변

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

아바타
취소