This question has been flagged
1 Reply
3980 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