I used this code to remove spaces on the phone in clients
But I want to modify the customer numbers that already exist. The code is only applied to the customers that we enter recently after add code
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.onchange("phone")
def remove_spaces_from_phone_number(self):
for record in self:
if record.phone:
record.phone = record.phone.replace(" ", "")
@api.onchange("mobile")
def remove_spaces_from_mobile_number(self):
for record in self:
if record.mobile:
record.mobile = record.mobile.replace(" ", "")
@api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): args = args or []
domain = []
if name:
domain = ['|', '|', ('name', operator, name), ('mobile', operator, name), ('phone', operator, name)]
return self._search(domain + args, limit=limit, access_rights_uid=name_get_uid)
@api.onchange("phone")
def remove_spaces_from_phone_number(self):
partner_ids = self.env['res.partner'].search([('phone','!=', False)])
for record in partner_ids:
if record.phone:
record.phone = record.phone.replace(" ", "")
please use the above code for modifying the customer numbers that already exist.after running this you can use your code.
apper message
Validation Error
Similiar Value already exists in this partners