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.2 KiB

  1. # Copyright 2020 Camptocamp SA
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
  3. from odoo.tests.common import SavepointCase
  4. class TestPartnerTitle(SavepointCase):
  5. @classmethod
  6. def setUpClass(cls):
  7. super().setUpClass()
  8. cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
  9. def test_default_order(self):
  10. partner_titles = self.env["res.partner.title"].search([])
  11. self.assertEqual(
  12. partner_titles.mapped("name"),
  13. partner_titles.sorted(lambda x: x.name).mapped("name"),
  14. )
  15. def test_sequence_order(self):
  16. partner_titles = self.env["res.partner.title"].search([])
  17. partner_first = partner_titles[0]
  18. partner_first.sequence = 100
  19. partner_last = partner_titles[-1]
  20. partner_last.sequence = 0
  21. partner_titles = self.env["res.partner.title"].search([])
  22. self.assertEqual(
  23. partner_titles.mapped("name"),
  24. partner_titles.sorted(lambda x: (x.sequence, x.name)).mapped("name"),
  25. )
  26. # last and first inverted
  27. self.assertEqual(partner_titles[0], partner_last)
  28. self.assertEqual(partner_titles[-1], partner_first)