diff --git a/base_phone/fields.py b/base_phone/fields.py index e90f843..95541f9 100644 --- a/base_phone/fields.py +++ b/base_phone/fields.py @@ -94,7 +94,9 @@ def convert_all_phone_fields(self, vals, fields_to_convert): country_code = False if country: country_code = country.code.upper() - loc_vals[field] = convert_phone_field(loc_vals[field], country_code) + if loc_vals[field]: + loc_vals[field] = convert_phone_field( + loc_vals[field], country_code) return loc_vals diff --git a/base_phone/test/phonenum.yml b/base_phone/test/phonenum.yml index 27aa6d7..ac8726c 100644 --- a/base_phone/test/phonenum.yml +++ b/base_phone/test/phonenum.yml @@ -29,11 +29,11 @@ - !python {model: res.partner}: | partner1 = self.browse(cr, uid, ref('partner1'), context=context) - assert partner1.mobile == '+33642774266', 'Mobile number not written in E.164 format (partner1)' - assert partner1.fax == '+33145421242', 'Fax number not written in E.164 format (partner1)' + assert partner1.mobile == '+33 6 42 77 42 66', 'Mobile number not written in E.164 format (partner1)' + assert partner1.fax == '+33 1 45 42 12 42', 'Fax number not written in E.164 format (partner1)' partner2 = self.browse(cr, uid, ref('partner2'), context=context) - assert partner2.phone == '+41216191010', 'Phone number not written in E.164 format (partner2)' - assert partner2.mobile == '+41796064242', 'Mobile number not written in E.164 format (partner2)' + assert partner2.phone == '+41 21 619 10 10', 'Phone number not written in E.164 format (partner2)' + assert partner2.mobile == '+41 79 606 42 42', 'Mobile number not written in E.164 format (partner2)' - Check that invalid phone numbers are kept unchanged - diff --git a/crm_phone/crm_phone.py b/crm_phone/crm_phone.py index 380ee81..387fa1e 100644 --- a/crm_phone/crm_phone.py +++ b/crm_phone/crm_phone.py @@ -12,7 +12,7 @@ class CrmLead(models.Model): phone = Phone(country_field='country_id') mobile = Phone(country_field='country_id') - phone = Phone(country_field='country_id') + fax = Phone(country_field='country_id') phonecall_ids = fields.One2many( 'crm.phonecall', 'opportunity_id', string='Phone Calls') phonecall_count = fields.Integer( diff --git a/crm_phone/test/phonenum.yml b/crm_phone/test/phonenum.yml index 25aa860..b64074b 100644 --- a/crm_phone/test/phonenum.yml +++ b/crm_phone/test/phonenum.yml @@ -24,13 +24,13 @@ - !python {model: crm.lead}: | lead1 = self.browse(cr, uid, ref('lead1'), context=context) - assert lead1.mobile == '+33642774277', 'Mobile number not written in E.164 format (lead1)' - assert lead1.fax == '+33145444243', 'Fax number not written in E.164 format (lead1)' + assert lead1.mobile == '+33 6 42 77 42 77', 'Mobile number not written in E.164 format (lead1)' + assert lead1.fax == '+33 1 45 44 42 43', 'Fax number not written in E.164 format (lead1)' lead2 = self.browse(cr, uid, ref('lead2'), context=context) - assert lead2.phone == '+41431234567', 'Phone number not written in E.164 format (lead2)' - self.write(cr, uid, ref('lead3'), {'phone': '0891234567'}) + assert lead2.phone == '+41 43 123 45 67', 'Phone number not written in E.164 format (lead2)' + self.write(cr, uid, ref('lead3'), {'phone': '08912345678'}) lead3 = self.browse(cr, uid, ref('lead3'), context=context) - assert lead3.phone == '+49891234567', 'Phone number not written in E.164 format (lead3)' + assert lead3.phone == '+49 89 12345678', 'Phone number not written in E.164 format (lead3)' - Get name from phone number -