跳至內容
選單
此問題已被標幟
1 回覆
7278 瀏覽次數

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

頭像
捨棄
最佳答案

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

 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
12月 19
3714
0
8月 20
4496
4
8月 20
9236
3
11月 23
17293
3
11月 24
24870