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.

38 lines
1.4 KiB

  1. # Copyright 2016 Tecnativa - Pedro M. Baeza <pedro.baeza@tecnativa.com>
  2. # Copyright 2017 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com>
  3. # Copyright 2018 Tecnativa - Cristina Martín
  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. """First empty the field for filling it again afterwards to see if
  29. the contact gets the same value.
  30. """
  31. self.partner.lang = False
  32. self.partner.lang = 'en_US'
  33. self.assertEqual(self.contact.lang, 'en_US')