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.

40 lines
1.4 KiB

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