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.

51 lines
1.9 KiB

  1. # Copyright 2017 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo.exceptions import ValidationError
  4. from odoo.tests.common import TransactionCase
  5. class TestIrExportsLine(TransactionCase):
  6. def setUp(self):
  7. super(TestIrExportsLine, self).setUp()
  8. self.ir_export = self.env.ref("base_jsonify.ir_exp_partner")
  9. def test_alias_contrains(self):
  10. ir_export_lines_model = self.env["ir.exports.line"]
  11. with self.assertRaises(ValidationError):
  12. # The field into the name must be also into the alias
  13. ir_export_lines_model.create(
  14. {
  15. "export_id": self.ir_export.id,
  16. "name": "name",
  17. "alias": "toto:my_alias",
  18. }
  19. )
  20. with self.assertRaises(ValidationError):
  21. # The hierarchy into the alias must be the same as the one into
  22. # the name
  23. ir_export_lines_model.create(
  24. {
  25. "export_id": self.ir_export.id,
  26. "name": "child_ids/child_ids/name",
  27. "alias": "child_ids:children/name",
  28. }
  29. )
  30. with self.assertRaises(ValidationError):
  31. # The hierarchy into the alias must be the same as the one into
  32. # the name and must contains the same fields as into the name
  33. ir_export_lines_model.create(
  34. {
  35. "export_id": self.ir_export.id,
  36. "name": "child_ids/child_ids/name",
  37. "alias": "child_ids:children/category_id:category/name",
  38. }
  39. )
  40. line = ir_export_lines_model.create(
  41. {
  42. "export_id": self.ir_export.id,
  43. "name": "child_ids/child_ids/name",
  44. "alias": "child_ids:children/child_ids:children/name",
  45. }
  46. )
  47. self.assertTrue(line)