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.

47 lines
1.8 KiB

  1. # Copyright 2019-2020 Onestein (<https://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 TestBase(TransactionCase):
  5. def setUp(self):
  6. super().setUp()
  7. Partner = self.env["res.partner"]
  8. self.p1 = Partner.browse(Partner.name_create("Parent")[0])
  9. self.c1 = Partner.create({"name": "Child 1", "parent_id": self.p1.id})
  10. self.c11 = Partner.create({"name": "Grand-Child 1.1", "parent_id": self.c1.id})
  11. self.c2 = Partner.create({"name": "Child 2", "parent_id": self.p1.id})
  12. def test_01_archive_partners(self):
  13. self.assertTrue(self.p1.active)
  14. self.assertTrue(self.c1.active)
  15. self.assertTrue(self.c11.active)
  16. self.assertTrue(self.c2.active)
  17. # archive the parent partner, skip the archive of contacts
  18. self.p1.with_context(skip_child_toggle_active=True).toggle_active()
  19. self.assertFalse(self.p1.active)
  20. self.assertTrue(self.c1.active)
  21. self.assertTrue(self.c11.active)
  22. self.assertTrue(self.c2.active)
  23. # unarchive the parent partner
  24. self.p1.toggle_active()
  25. self.assertTrue(self.c1.active)
  26. self.assertTrue(self.c11.active)
  27. self.assertTrue(self.c2.active)
  28. # archive the parent partner, automatically archive contacts
  29. self.p1.toggle_active()
  30. self.assertFalse(self.p1.active)
  31. self.assertFalse(self.c1.active)
  32. self.assertFalse(self.c11.active)
  33. self.assertFalse(self.c2.active)
  34. # unarchive the parent partner
  35. self.p1.toggle_active()
  36. self.assertTrue(self.p1.active)
  37. self.assertFalse(self.c1.active)
  38. self.assertFalse(self.c11.active)
  39. self.assertFalse(self.c2.active)