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.

53 lines
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016-2018 Akretion France
  3. # @author: Alexis de Lattre <alexis.delattre@akretion.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo.tests.common import TransactionCase
  6. class TestCRMPhone(TransactionCase):
  7. def test_crm_phone(self):
  8. clo = self.env['crm.lead']
  9. lead1 = clo.create({
  10. 'name': 'The super deal of the year !',
  11. 'partner_name': 'Ford',
  12. 'contact_name': 'Jacques Toufaux',
  13. 'mobile': '06.42.77.42.77',
  14. 'country_id': self.env.ref('base.fr').id,
  15. })
  16. lead1._onchange_mobile_validation()
  17. self.assertEquals(lead1.mobile, u'+33 6 42 77 42 77')
  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. lead2._onchange_phone_validation()
  26. self.assertEquals(lead2.phone, u'+41 43 123 45 67')
  27. lead3 = clo.create({
  28. 'name': 'Angela Strasse',
  29. 'country_id': self.env.ref('base.de').id,
  30. 'phone': '08912345678',
  31. })
  32. lead3._onchange_phone_validation()
  33. self.assertEquals(lead3.phone, u'+49 89 12345678')
  34. partner4 = self.env['res.partner'].create({
  35. 'name': 'Belgian Guy',
  36. 'country_id': self.env.ref('base.be').id,
  37. })
  38. lead4 = clo.create({
  39. 'name': 'Large Odoo deployment',
  40. 'partner_id': partner4.id,
  41. 'mobile': '(0) 2-391-43-75',
  42. })
  43. lead4._onchange_mobile_validation()
  44. self.assertEquals(lead4.mobile, u'+32 2 391 43 75')
  45. pco = self.env['phone.common']
  46. name = pco.get_name_from_phone_number('0642774277')
  47. self.assertEquals(name, 'Jacques Toufaux (Ford)')
  48. name2 = pco.get_name_from_phone_number('0041431234567')
  49. self.assertEquals(name2, u'Mikaël Content (Kia)')