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.

33 lines
1.3 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 (https://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({"name": "Partner test", "lang": "en_US"})
  12. cls.contact = cls.ResPartner.create(
  13. {"name": "Contact test", "lang": False, "parent_id": cls.partner.id}
  14. )
  15. def test_onchange_parent_id(self):
  16. self.contact.parent_id = False
  17. res = self.contact.onchange_parent_id()
  18. self.assertIsNone(res)
  19. self.contact.parent_id = self.partner
  20. res = self.contact.onchange_parent_id()
  21. self.assertEqual(self.contact.lang, "en_US")
  22. def test_write_parent_lang(self):
  23. """First empty the field for filling it again afterwards to see if
  24. the contact gets the same value.
  25. """
  26. self.partner.lang = False
  27. self.partner.lang = "en_US"
  28. self.assertEqual(self.contact.lang, "en_US")