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.

35 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  3. # Copyright 2017 Vicent Cubells <vicent.cubells@tecnativa.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo.tests import common
  6. class TestPartnerContactLang(common.SavepointCase):
  7. @classmethod
  8. def setUpClass(cls):
  9. super(TestPartnerContactLang, cls).setUpClass()
  10. cls.ResPartner = cls.env['res.partner']
  11. cls.partner = cls.ResPartner.create({
  12. 'name': 'Partner test',
  13. 'lang': 'en_US',
  14. })
  15. cls.contact = cls.ResPartner.create({
  16. 'name': 'Contact test',
  17. 'lang': False,
  18. 'parent_id': cls.partner.id,
  19. })
  20. def test_onchange_parent_id(self):
  21. self.contact.parent_id = False
  22. res = self.contact.onchange_parent_id()
  23. self.assertIsNone(res)
  24. self.contact.parent_id = self.partner
  25. res = self.contact.onchange_parent_id()
  26. self.assertEqual(res.get('value', {}).get('lang'), 'en_US')
  27. def test_write_parent_lang(self):
  28. self.partner.lang = False
  29. self.partner.lang = 'en_US'
  30. self.assertEqual(self.contact.lang, 'en_US')