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.

45 lines
1.8 KiB

  1. -
  2. Write french phone numbers in national format
  3. -
  4. !record {model: res.partner, id: partner1}:
  5. name: Pierre Paillet
  6. mobile: 06 42 77 42 66
  7. fax: (0) 1 45 42 12 42
  8. -
  9. Write swiss phone numbers in international format
  10. -
  11. !record {model: res.partner, id: partner2}:
  12. name: Joël Grand-Guillaume
  13. parent_id: base.res_partner_12
  14. phone: +41 21 619 10 10
  15. mobile: +41 79 606 42 42
  16. -
  17. Write invalid phone number
  18. -
  19. !record {model: res.partner, id: partner3}:
  20. name: Jean Badphone
  21. phone: 42
  22. -
  23. Check that valid phone numbers have been converted to E.164
  24. -
  25. !python {model: res.partner}: |
  26. partner1 = self.browse(cr, uid, ref('partner1'), context=context)
  27. assert partner1.mobile == '+33642774266', 'Mobile number not written in E.164 format (partner1)'
  28. assert partner1.fax == '+33145421242', 'Fax number not written in E.164 format (partner1)'
  29. partner2 = self.browse(cr, uid, ref('partner2'), context=context)
  30. assert partner2.phone == '+41216191010', 'Phone number not written in E.164 format (partner2)'
  31. assert partner2.mobile == '+41796064242', 'Mobile number not written in E.164 format (partner2)'
  32. -
  33. Check that invalid phone numbers are kept unchanged
  34. -
  35. !python {model: res.partner}: |
  36. partner3 = self.browse(cr, uid, ref('partner3'), context=context)
  37. assert partner3.phone == '42', 'Invalid phone numbers should not be changed'
  38. -
  39. Get name from phone number
  40. -
  41. !python {model: phone.common}: |
  42. name = self.get_name_from_phone_number(cr, uid, '0642774266')
  43. assert name == 'Pierre Paillet', 'Wrong result for get_name_from_phone_number'
  44. name2 = self.get_name_from_phone_number(cr, uid, '0041216191010')
  45. assert name2 == u'Joël Grand-Guillaume (Camptocamp)', 'Wrong result for get_name_from_phone_number (partner2)'