Я пытался реализовать ограничение для поля, но вместо того, чтобы вызывать проверку ограничения, он позволяет сохранить запись без отображения какого-либо сообщения об ограничении.
def _check_contact_number(self, cr, uid, ids, context=None):
for rec in self.browse(cr, uid, ids, context=context):
if rec.contact_number:
size=len(str(rec.contact_number))
if size<10:
return False
if not contact_number:
return {}
contact_number = rec.contact_number.replace('.','')
#removes any '.' from the string
contact_number = rec.contact_number.replace(' ','')
#removes space from the string
if not contact_number.isdigit():
return False
return {}
_constraints = [
(_check_contact_number, 'Enter valid phone number...!',
['contact_number']),
]
Пожалуйста, поправьте меня. Большое спасибо