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. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. class TestCRMPhone(TransactionCase):
  6. def test_crm_phone(self):
  7. clo = self.env['crm.lead']
  8. lead1 = clo.create({
  9. 'name': 'The super deal of the year !',
  10. 'partner_name': 'Ford',
  11. 'contact_name': 'Jacques Toufaux',
  12. 'mobile': '06.42.77.42.77',
  13. 'fax': '(0) 1 45 44 42 43',
  14. 'country_id': self.env.ref('base.fr').id,
  15. })
  16. self.assertEquals(lead1.mobile, u'+33 6 42 77 42 77')
  17. self.assertEquals(lead1.fax, u'+33 1 45 44 42 43')
  18. lead2 = clo.create({
  19. 'name': u'Automobile Odoo deployment',
  20. 'partner_name': u'Kia',
  21. 'contact_name': u'Mikaël Content',
  22. 'country_id': self.env.ref('base.ch').id,
  23. 'phone': '04 31 23 45 67',
  24. })
  25. self.assertEquals(lead2.phone, u'+41 43 123 45 67')
  26. lead3 = clo.create({
  27. 'name': 'Angela Strasse',
  28. 'country_id': self.env.ref('base.de').id,
  29. })
  30. lead3.write({'phone': '08912345678'})
  31. self.assertEquals(lead3.phone, u'+49 89 12345678')
  32. lead4 = clo.create({
  33. 'name': 'Large Odoo deployment',
  34. 'partner_id': self.env.ref('base.res_partner_2').id,
  35. })
  36. lead4.write({'mobile': '(0) 2-391-43-75'})
  37. self.assertEquals(lead4.mobile, u'+32 2 391 43 75')
  38. pco = self.env['phone.common']
  39. name = pco.get_name_from_phone_number('0642774277')
  40. self.assertEquals(name, 'Jacques Toufaux (Ford)')
  41. name2 = pco.get_name_from_phone_number('0041431234567')
  42. self.assertEquals(name2, u'Mikaël Content (Kia)')