Hello all,
I have a integer field 'is_mobile'. Where user entering mobile. I want that when user enter wrong mobile no. format then it show warning message "invalid no. format" and also form not save without right format. For this i applied code, but it is not work as per requirement.
Code is below:
is_mobile = fields.Integer("Mobile")
@api.multi
@api.constrains('is_mobile')
def _check_phone_number(self):
for rec in self:
if rec.is_mobile and len(rec.is_mobile) != "^[0-9]{10}$" :
raise ValidationError(_("Wrong value enter"))
else:
return False
return {}
Thanks in advance