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.

44 lines
1.7 KiB

  1. # © 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. 'export_id': self.ir_export.id,
  15. 'name': 'name',
  16. 'alias': 'toto:my_alias'
  17. })
  18. with self.assertRaises(ValidationError):
  19. # The hierarchy into the alias must be the same as the one into
  20. # the name
  21. ir_export_lines_model.create({
  22. 'export_id': self.ir_export.id,
  23. 'name': 'child_ids/child_ids/name',
  24. 'alias': 'child_ids:children/name'
  25. })
  26. with self.assertRaises(ValidationError):
  27. # The hierarchy into the alias must be the same as the one into
  28. # the name and must contains the same fields as into the name
  29. ir_export_lines_model.create({
  30. 'export_id': self.ir_export.id,
  31. 'name': 'child_ids/child_ids/name',
  32. 'alias': 'child_ids:children/category_id:category/name'
  33. })
  34. line = ir_export_lines_model.create({
  35. 'export_id': self.ir_export.id,
  36. 'name': 'child_ids/child_ids/name',
  37. 'alias': 'child_ids:children/child_ids:children/name'
  38. })
  39. self.assertTrue(line)