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.

36 lines
1.5 KiB

  1. # Copyright 2017 Onestein (<http://www.onestein.eu>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo.tests.common import TransactionCase
  4. class TestOnchangeHelper(TransactionCase):
  5. def test01_partner_parent(self):
  6. main_partner = self.env.ref('base.main_partner')
  7. input_vals = dict(parent_id=main_partner.id, type='contact')
  8. updated_vals = self.env['res.partner'].play_onchanges(
  9. input_vals, ['parent_id']
  10. )
  11. self.assertIn('country_id', updated_vals)
  12. self.assertIn('state_id', updated_vals)
  13. self.assertIn('street', updated_vals)
  14. self.assertIn('zip', updated_vals)
  15. self.assertEqual(
  16. updated_vals['country_id'], main_partner.country_id.id
  17. )
  18. self.assertEqual(updated_vals['state_id'], main_partner.state_id.id)
  19. self.assertEqual(updated_vals['street'], main_partner.street)
  20. self.assertEqual(updated_vals['zip'], main_partner.zip)
  21. def test02_partner_country(self):
  22. partner_demo = self.env.ref('base.partner_demo')
  23. input_vals = {'country_id': self.env.ref('base.us').id}
  24. updated_vals = partner_demo.play_onchanges(input_vals, ['country_id'])
  25. self.assertIn('country_id', updated_vals)
  26. def test_playing_onchange_on_model(self):
  27. result = self.env['res.partner'].play_onchanges(
  28. {'company_type': 'company'}, ['company_type']
  29. )
  30. self.assertEqual(result['is_company'], True)