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.

49 lines
2.0 KiB

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