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
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Yannick Vaucher (Camptocamp)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. """Test a city completion and onchanges."""
  5. from openerp.tests.common import TransactionCase
  6. class TestCompletion(TransactionCase):
  7. def test_onchange_better_zip_state_id(self):
  8. """ Test onchange on res.better.zip """
  9. usa_MA = self.env.ref('base.state_us_34')
  10. self.better_zip1.state_id = usa_MA
  11. self.better_zip1.onchange_state_id()
  12. self.assertEqual(self.better_zip1.country_id, usa_MA.country_id)
  13. def test_onchange_partner_city_completion(self):
  14. self.partner1.zip_id = self.better_zip1
  15. self.partner1.onchange_zip_id()
  16. self.assertEqual(self.partner1.zip, self.better_zip1.name)
  17. self.assertEqual(self.partner1.city, self.better_zip1.city)
  18. self.assertEqual(self.partner1.state_id, self.better_zip1.state_id)
  19. self.assertEqual(self.partner1.country_id, self.better_zip1.country_id)
  20. def test_onchange_company_city_completion(self):
  21. self.company.better_zip_id = self.better_zip1
  22. self.company.on_change_city()
  23. self.assertEqual(self.company.zip, self.better_zip1.name)
  24. self.assertEqual(self.company.city, self.better_zip1.city)
  25. self.assertEqual(self.company.state_id, self.better_zip1.state_id)
  26. self.assertEqual(self.company.country_id, self.better_zip1.country_id)
  27. def setUp(self):
  28. super(TestCompletion, self).setUp()
  29. state_vd = self.env['res.country.state'].create({
  30. 'name': 'Vaud',
  31. 'code': 'VD',
  32. 'country_id': self.ref('base.ch'),
  33. })
  34. self.company = self.env.ref('base.main_company')
  35. self.better_zip1 = self.env['res.better.zip'].create({
  36. 'name': 1000,
  37. 'city': 'Lausanne',
  38. 'state_id': state_vd.id,
  39. 'country_id': self.ref('base.ch'),
  40. })
  41. self.partner1 = self.env['res.partner'].create({
  42. 'name': 'Camptocamp',
  43. })