Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
7265 Visualizações

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
Cancelar
Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
2
dez. 19
3711
0
ago. 20
4493
4
ago. 20
9231
3
nov. 23
17275
3
nov. 24
24861