Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7282 มุมมอง

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

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Overriding "Product" in odoo 12 website? แก้ไขแล้ว
2
ธ.ค. 19
3715
0
ส.ค. 20
4496
4
ส.ค. 20
9236
How to track One2many field in Odoo12? แก้ไขแล้ว
3
พ.ย. 23
17293
Error: Couldn't load module web แก้ไขแล้ว
3
พ.ย. 24
24872