You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Akretion France (Alexis de Lattre <alexis.delattre@akretion.com>)
  3. from openerp.tests.common import TransactionCase
  4. class TestCRMPhone(TransactionCase):
  5. def test_crm_phone(self):
  6. clo = self.env['crm.lead']
  7. lead1 = clo.create({
  8. 'name': 'The super deal of the year !',
  9. 'partner_name': 'Ford',
  10. 'contact_name': 'Jacques Toufaux',
  11. 'mobile': '06.42.77.42.77',
  12. 'fax': '(0) 1 45 44 42 43',
  13. 'country_id': self.env.ref('base.fr').id,
  14. })
  15. self.assertEquals(lead1.mobile, u'+33 6 42 77 42 77')
  16. self.assertEquals(lead1.fax, u'+33 1 45 44 42 43')
  17. lead2 = clo.create({
  18. 'name': u'Automobile Odoo deployment',
  19. 'partner_name': u'Kia',
  20. 'contact_name': u'Mikaël Content',
  21. 'country_id': self.env.ref('base.ch').id,
  22. 'phone': '04 31 23 45 67',
  23. })
  24. self.assertEquals(lead2.phone, u'+41 43 123 45 67')
  25. lead3 = clo.create({
  26. 'name': 'Angela Strasse',
  27. 'country_id': self.env.ref('base.de').id,
  28. })
  29. lead3.write({'phone': '08912345678'})
  30. self.assertEquals(lead3.phone, u'+49 89 12345678')
  31. lead4 = clo.create({
  32. 'name': 'Large Odoo deployment',
  33. 'partner_id': self.env.ref('base.res_partner_2').id,
  34. })
  35. lead4.write({'mobile': '(0) 2-391-43-75'})
  36. self.assertEquals(lead4.mobile, u'+32 2 391 43 75')
  37. pco = self.env['phone.common']
  38. name = pco.get_name_from_phone_number('0642774277')
  39. self.assertEquals(name, 'Jacques Toufaux (Ford)')
  40. name2 = pco.get_name_from_phone_number('0041431234567')
  41. self.assertEquals(name2, u'Mikaël Content (Kia)')