diff --git a/addons/crm/views/res_config_settings_views.xml b/addons/crm/views/res_config_settings_views.xml
index e06b7c9f7ec..43c7207d5d1 100644
--- a/addons/crm/views/res_config_settings_views.xml
+++ b/addons/crm/views/res_config_settings_views.xml
@@ -61,7 +61,7 @@
- Validate and normalize phone numbers.
+ Formats phone numbers
diff --git a/addons/crm_phone_validation/__manifest__.py b/addons/crm_phone_validation/__manifest__.py
index 72a21dbfcfa..7c729bfae3e 100644
--- a/addons/crm_phone_validation/__manifest__.py
+++ b/addons/crm_phone_validation/__manifest__.py
@@ -13,7 +13,6 @@ CRM Phone Numbers Validation
This module allows for validate and format phone numbers for leads and contacts.""",
'data': [
'views/res_config_settings_views.xml',
- 'views/crm_lead_views.xml'
],
'depends': [
'phone_validation',
diff --git a/addons/crm_phone_validation/views/crm_lead_views.xml b/addons/crm_phone_validation/views/crm_lead_views.xml
deleted file mode 100644
index bcf1840bd7a..00000000000
--- a/addons/crm_phone_validation/views/crm_lead_views.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- crm.lead.form.opportunity.inherit.crm.phone.validation
- crm.lead
-
-
-
-
-
-
-
-
diff --git a/addons/phone_validation/models/phone_validation_mixin.py b/addons/phone_validation/models/phone_validation_mixin.py
index 4cd9d8eb2bb..02e4c6aa82a 100644
--- a/addons/phone_validation/models/phone_validation_mixin.py
+++ b/addons/phone_validation/models/phone_validation_mixin.py
@@ -9,11 +9,12 @@ class PhoneValidationMixin(models.AbstractModel):
_name = 'phone.validation.mixin'
def _phone_get_country(self):
- if 'country_id' in self:
+ if 'country_id' in self and self.country_id:
return self.country_id
+ return self.env.user.company_id.country_id
def _phone_get_always_international(self):
- if 'company_id' in self and self.country_id:
+ if 'company_id' in self and self.company_id:
return self.company_id.phone_international_format == 'prefix'
return self.env.user.company_id.phone_international_format == 'prefix'
diff --git a/addons/website_crm_phone_validation/controllers/website_form.py b/addons/website_crm_phone_validation/controllers/website_form.py
index 3713fe86f9e..c404bb87724 100644
--- a/addons/website_crm_phone_validation/controllers/website_form.py
+++ b/addons/website_crm_phone_validation/controllers/website_form.py
@@ -4,8 +4,6 @@
from odoo.addons.website_form.controllers.main import WebsiteForm
from odoo.http import request, route
-import json
-
class WebsiteForm(WebsiteForm):
@@ -32,17 +30,13 @@ class WebsiteForm(WebsiteForm):
else:
record = data.get('record', {})
phone_fields = self._get_phone_fields_to_validate()
- country = self._get_country()
- invalid_fields = {}
+ country = request.env['res.country'].browse(record.get('country_id'))
+ contact_country = country.exists() and country or self._get_country()
for phone_field in phone_fields:
if not record.get(phone_field):
continue
number = record[phone_field]
- try:
- request.env[model_name].phone_format(number, country)
- except Exception as error:
- invalid_fields[phone_field] = error.args[0]
- if invalid_fields:
- return json.dumps({'error_fields': invalid_fields})
+ fmt_number = request.env[model_name].phone_format(number, contact_country)
+ request.params.update({phone_field: fmt_number})
return super(WebsiteForm, self).website_form(model_name, **kwargs)