Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
7261 Vistas

Hello All,

I'm working on sign up process for the user. Where I taking the phone from the user before sign up. And I want to show the validation when wrong phone number format.

My phone number format code in controller file is below:

def passwordless_signup(self, values, qcontext):
.
.
.
if values['phone']:
phone_fields = self._get_phone_fields_to_validate()
for phone_field in phone_fields:
number = values['phone']
fmt_number = request.env['res.partner'].phone_format(number)
request.params.update({phone_field: number})
.
.
.
return request.render("auth_signup.reset_password", qcontext)

On Ubuntu Terminal, I'm getting below error and I want to show this as validation for user:

File "/opt/odoo12/odoo/addons/phone_validation/tools/phone_validation.py", line 25, in phone_parse
raise UserError(_('Invalid number %s: probably incorrect prefix') % number)
odoo.exceptions.UserError: ('Invalid number 4545545: probably incorrect prefix', '')

Thanks in advance

Avatar
Descartar
Mejor respuesta

Odoo phone_validation module use python-phonenumbers library to validate provided phone number with country

check provided phone number format match with country/region code

ref: https://github.com/daviddrysdale/python-phonenumbers

 

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
dic 19
3708
0
ago 20
4485
4
ago 20
9226
3
nov 23
17271
3
nov 24
24848