Skip to Content
Menu
This question has been flagged
1 Reply
4262 Views

Hello All,

I want to remove space and '-' between the mobile number in odoo v13. Currently my mobile number format like this '+977 960-2582808'. From this format i want to remove space and  '-'. This is mobile field in res.partner table with widget="phone".

expected result: +9779602582808

I am trying below code:

login_mobile = fields.Char()
mobile_sanitized = fields.Char(string='Mobile Number')
   
@api.onchange("login_mobile")
def onchange_device_id(self):
    print('aaaaaaaaaaaaa')
    self.mobile_sanitized = self.login_mobile.strip(' ')


Thanks in advance.

Avatar
Discard
Best Answer

Hello Pawan Sharma,

You can use the 're' library of python for this:

just use 'import re' and then in your code,

you can use something like this:

self.mobile_sanitized = re.sub (r '\ s +', '', self.mobile_sanitized) .replace ("-", "")


Thanks ..

For more information Contact us:- https: //kanakinfosystems.com/odoo-development-services

Avatar
Discard
Related Posts Replies Views Activity
4
May 24
10066
1
Apr 24
1561
0
Nov 23
525
1
Sep 23
562
2
Aug 23
2421