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

6 years ago
  1. # Copyright 2015 Antiun Ingenieria S.L. - Antonio Espinosa
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests.common import TransactionCase
  4. class PartnerNamesOrder(TransactionCase):
  5. def order_set(self, order):
  6. config = self.env["res.config.settings"].create({"partner_names_order": order})
  7. config.execute()
  8. def test_get_computed_name(self):
  9. lastname = "García Lorca"
  10. firstname = "Federico"
  11. cases = (
  12. ("last_first", "García Lorca Federico"),
  13. ("last_first_comma", "García Lorca, Federico"),
  14. ("first_last", "Federico García Lorca"),
  15. )
  16. for order, name in cases:
  17. self.order_set(order)
  18. result = self.env["res.partner"]._get_computed_name(lastname, firstname)
  19. self.assertEqual(result, name)
  20. def test_get_inverse_name(self):
  21. lastname = "Flanker"
  22. firstname = "Petër"
  23. cases = (
  24. ("last_first", "Flanker Petër"),
  25. ("last_first_comma", "Flanker, Petër"),
  26. ("first_last", "Petër Flanker"),
  27. )
  28. for order, name in cases:
  29. self.order_set(order)
  30. result = self.env["res.partner"]._get_inverse_name(name)
  31. self.assertEqual(result["lastname"], lastname)
  32. self.assertEqual(result["firstname"], firstname)