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.

45 lines
1.8 KiB

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