summaryrefslogtreecommitdiff
path: root/addons/phone_validation/models
diff options
context:
space:
mode:
authorRémi Rahir <rar@odoo.com>2018-02-09 15:24:54 +0100
committerRémi Rahir <rar@odoo.com>2018-02-12 09:16:17 +0100
commit8b9bcf1b7efff6423763f69aad171c7c98dce5bc (patch)
tree601d8b39d888b1559cf2683eaa366f3d8d9778b9 /addons/phone_validation/models
parent26468bfaba1dacd05e9bdc534c98fbcc4076eae4 (diff)
[FIX] crm_phone_validation: fix lead phone validation
Fixes country_id and company_id mismatch in 65832dc. Removes the view added by said commit as it was not a true stable fix since it required users to update the module. This commit uses a workaround to get the missing company_id field which is monkey-patching the fields_view_get of the model, as suggested by rco. This commit also removes the exception catches that were rendered useless by the False value given to the raise_exception parameter of phone_format, introduced in 65832dc as well. This commits fixes the behaviour in the website form as the phone numbers were sanitized but never saved as such on their record. This commit also renames the Phone Validation config setting to suit its true functionality.
Diffstat (limited to 'addons/phone_validation/models')
-rw-r--r--addons/phone_validation/models/phone_validation_mixin.py5
1 files changed, 3 insertions, 2 deletions
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'