Browse Source

Port YAML tests to new fields.Phone archi

Fix bugs
pull/88/head
Alexis de Lattre 9 years ago
parent
commit
09f47031f8
  1. 4
      base_phone/fields.py
  2. 8
      base_phone/test/phonenum.yml
  3. 2
      crm_phone/crm_phone.py
  4. 10
      crm_phone/test/phonenum.yml

4
base_phone/fields.py

@ -94,7 +94,9 @@ def convert_all_phone_fields(self, vals, fields_to_convert):
country_code = False country_code = False
if country: if country:
country_code = country.code.upper() 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 return loc_vals

8
base_phone/test/phonenum.yml

@ -29,11 +29,11 @@
- -
!python {model: res.partner}: | !python {model: res.partner}: |
partner1 = self.browse(cr, uid, ref('partner1'), context=context) 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) 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 Check that invalid phone numbers are kept unchanged
- -

2
crm_phone/crm_phone.py

@ -12,7 +12,7 @@ class CrmLead(models.Model):
phone = Phone(country_field='country_id') phone = Phone(country_field='country_id')
mobile = 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( phonecall_ids = fields.One2many(
'crm.phonecall', 'opportunity_id', string='Phone Calls') 'crm.phonecall', 'opportunity_id', string='Phone Calls')
phonecall_count = fields.Integer( phonecall_count = fields.Integer(

10
crm_phone/test/phonenum.yml

@ -24,13 +24,13 @@
- -
!python {model: crm.lead}: | !python {model: crm.lead}: |
lead1 = self.browse(cr, uid, ref('lead1'), context=context) 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) 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) 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 Get name from phone number
- -

Loading…
Cancel
Save