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.

39 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. return self.env['ir.config_parameter'].sudo().set_param(
  7. 'partner_names_order', order)
  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(
  19. lastname, firstname)
  20. self.assertEqual(result, name)
  21. def test_get_inverse_name(self):
  22. lastname = "Flanker"
  23. firstname = "Petër"
  24. cases = (
  25. ('last_first', "Flanker Petër"),
  26. ('last_first_comma', "Flanker, Petër"),
  27. ('first_last', "Petër Flanker"),
  28. )
  29. for order, name in cases:
  30. self.order_set(order)
  31. result = self.env['res.partner']._get_inverse_name(name)
  32. self.assertEqual(result['lastname'], lastname)
  33. self.assertEqual(result['firstname'], firstname)