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.

50 lines
1.9 KiB

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