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.

88 lines
2.5 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Nicolas Bessi
  5. # Copyright 2014 Camptocamp SA
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. import openerp.tests.common as test_common
  22. class TestStreet3(test_common.TransactionCase):
  23. def test_partner(self):
  24. part_model = self.registry('res.partner')
  25. country_model = self.registry('res.country')
  26. country_id = country_model.create(
  27. self.cr,
  28. self.uid,
  29. {
  30. 'name': 'Donut Land',
  31. 'code': 'DNL',
  32. }
  33. )
  34. self.assertTrue(country_id)
  35. create_data = {
  36. 'name': 'Homer Simpson',
  37. 'city': 'Springfield',
  38. 'street': '742 Evergreen Terrace',
  39. 'street2': 'Donut Lane',
  40. 'street3': 'Tho',
  41. 'country_id': country_id,
  42. 'is_company': True
  43. }
  44. homer_id = part_model.create(
  45. self.cr,
  46. self.uid,
  47. create_data
  48. )
  49. homer = part_model.browse(
  50. self.cr,
  51. self.uid,
  52. homer_id,
  53. )
  54. self.assertEqual(
  55. homer.country_id.address_format,
  56. ("%(street)s\n%(street2)s\n%(street3)s\n"
  57. "%(city)s %(state_code)s %(zip)s\n"
  58. "%(country_name)s")
  59. )
  60. create_data = {
  61. 'name': 'Bart Simpson',
  62. 'is_company': False,
  63. 'parent_id': homer.id,
  64. 'use_parent_address': True
  65. }
  66. bart_id = part_model.create(
  67. self.cr,
  68. self.uid,
  69. create_data
  70. )
  71. bart = part_model.browse(
  72. self.cr,
  73. self.uid,
  74. bart_id,
  75. )
  76. self.assertTrue(bart.street3, 'Tho')