Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
7285 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
jouluk. 19
3715
0
elok. 20
4498
4
elok. 20
9237
3
marrask. 23
17294
3
marrask. 24
24880