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.

41 lines
1.6 KiB

  1. -
  2. Write french phone numbers in national format
  3. -
  4. !record {model: crm.lead, id: lead1}:
  5. name: Jacques Toufaux
  6. mobile: 06 42 77 42 77
  7. fax: (0) 1 45 44 42 43
  8. country_id: base.fr
  9. -
  10. Write swiss phone numbers in national format
  11. -
  12. !record {model: crm.lead, id: lead2}:
  13. name: Michel Content
  14. country_id: base.ch
  15. phone: 04 31 23 45 67
  16. -
  17. Create a german lead
  18. -
  19. !record {model: crm.lead, id: lead3}:
  20. name: Angela Strasse
  21. country_id: base.de
  22. -
  23. Check that valid phone numbers have been converted to E.164
  24. -
  25. !python {model: crm.lead}: |
  26. lead1 = self.browse(cr, uid, ref('lead1'), context=context)
  27. assert lead1.mobile == '+33642774277', 'Mobile number not written in E.164 format (lead1)'
  28. assert lead1.fax == '+33145444243', 'Fax number not written in E.164 format (lead1)'
  29. lead2 = self.browse(cr, uid, ref('lead2'), context=context)
  30. assert lead2.phone == '+41431234567', 'Phone number not written in E.164 format (lead2)'
  31. self.write(cr, uid, ref('lead3'), {'phone': '0891234567'})
  32. lead3 = self.browse(cr, uid, ref('lead3'), context=context)
  33. assert lead3.phone == '+49891234567', 'Phone number not written in E.164 format (lead3)'
  34. -
  35. Get name from phone number
  36. -
  37. !python {model: phone.common}: |
  38. name = self.get_name_from_phone_number(cr, uid, '0642774277')
  39. assert name == 'Jacques Toufaux', 'Wrong result for get_name_from_phone_number (lead1)'
  40. name2 = self.get_name_from_phone_number(cr, uid, '0041431234567')
  41. assert name2 == 'Michel Content', 'Wrong result for get_name_from_phone_number (lead2)'