[FIX] crm: get correct country for phone validation

Phone validation of crm_leads was using crm.lead country instead of partner
country code. This was leading to phone number of crm_case_16 coming from
an us partner validated as a uk phone number. (same problem applies for crm_case_14)

The problem was discovered in pre/post upgrade crawler test.

closes odoo/odoo#56348

X-original-commit: a58f9fc154c038d72031b281e2bec2c0fc2915ba
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2020-08-22 11:40:19 +00:00
parent 4da3f9cf1c
commit 5c33f1df58
+5
View File
@@ -322,6 +322,11 @@ class Lead(models.Model):
if lead.partner_id.phone and lead.phone != lead.partner_id.phone:
lead.phone = lead.partner_id.phone
def _phone_get_country(self):
if self.partner_id.country_id:
return self.partner_id.country_id
return super()._phone_get_country()
def _inverse_phone(self):
for lead in self:
if lead.partner_id and lead.phone != lead.partner_id.phone: