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.

99 lines
3.3 KiB

9.0 add date range Sorrento Delivery * [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
9 years ago
9.0 add date range Sorrento Delivery * [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
9 years ago
9.0 add date range Sorrento Delivery * [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
9 years ago
9.0 add date range Sorrento Delivery * [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
9 years ago
9.0 add date range Sorrento Delivery * [ADD] Basic structure for the new date range module * [IMP] Add a basic description into the README * [IMP] Basic implementation * [IMP] First working implementation * [IMP] Improve datamodel * [ADD] Add basic tests for date.range * [PEP8] * [PYLINT] * [DEL] Remove unused code * [IMP] Remove unsused dependencies into the JS * [IMP] Better operator label for date range * [DEL] Remove unused file * [IMP] Better user experience by showing the select input only once empty * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by adding an explicit cast on the daterange methods parameters * [FIX]Try to fix tests that fails only on travis by using postgresql 9.4 * [FIX]Try with postgresql 9.2 since the daterange method has appeared in 9.2 * [IMP] Add a limitation into the module description to warm about the minimal version of postgresql to use * [IMP]Add multi-company rules * [IMP]Remove unused files * [FIX] Add missing brackets into JS * [FIX] Overlap detection when company_id is False * [IMP] Add default order for date.range * [IMP] Add date range generator * [FIX] OE compatibility * [FIX] Travis * [IMP] Code cleanup and improves test coverage * [FIX] Add missing dependency on 'web' * [PYLINT] remove unused import * [FIX] Add missing copyright * [FIX] Limits are included into the range * [IMP][date_range] Security * [IMP] Improve module description * [IMP] Spelling
9 years ago
  1. # © 2016 ACSONE SA/NV (<http://acsone.eu>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
  3. from odoo.tests.common import TransactionCase
  4. from odoo.exceptions import ValidationError
  5. class DateRangeTest(TransactionCase):
  6. def setUp(self):
  7. super(DateRangeTest, self).setUp()
  8. self.type = self.env['date.range.type'].create(
  9. {'name': 'Fiscal year',
  10. 'company_id': False,
  11. 'allow_overlap': False})
  12. def test_default_company(self):
  13. date_range = self.env['date.range']
  14. dt = date_range.create({
  15. 'name': 'FS2016',
  16. 'date_start': '2015-01-01',
  17. 'date_end': '2016-12-31',
  18. 'type_id': self.type.id,
  19. })
  20. self.assertTrue(dt.company_id)
  21. # you can specify company_id to False
  22. dt = date_range.create({
  23. 'name': 'FS2016_NO_COMPANY',
  24. 'date_start': '2015-01-01',
  25. 'date_end': '2016-12-31',
  26. 'type_id': self.type.id,
  27. 'company_id': False
  28. })
  29. self.assertFalse(dt.company_id)
  30. def test_empty_company(self):
  31. date_range = self.env['date.range']
  32. dt = date_range.create({
  33. 'name': 'FS2016',
  34. 'date_start': '2015-01-01',
  35. 'date_end': '2016-12-31',
  36. 'type_id': self.type.id,
  37. 'company_id': None,
  38. })
  39. self.assertEqual(dt.name, 'FS2016')
  40. def test_invalid(self):
  41. date_range = self.env['date.range']
  42. with self.assertRaises(ValidationError) as cm:
  43. date_range.create({
  44. 'name': 'FS2016',
  45. 'date_end': '2015-01-01',
  46. 'date_start': '2016-12-31',
  47. 'type_id': self.type.id,
  48. })
  49. self.assertEqual(
  50. cm.exception.name,
  51. 'FS2016 is not a valid range (2016-12-31 > 2015-01-01)')
  52. def test_overlap(self):
  53. date_range = self.env['date.range']
  54. date_range.create({
  55. 'name': 'FS2015',
  56. 'date_start': '2015-01-01',
  57. 'date_end': '2015-12-31',
  58. 'type_id': self.type.id,
  59. })
  60. with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint():
  61. date_range.create({
  62. 'name': 'FS2016',
  63. 'date_start': '2015-01-01',
  64. 'date_end': '2016-12-31',
  65. 'type_id': self.type.id,
  66. })
  67. self.assertEqual(cm.exception.name, 'FS2016 overlaps FS2015')
  68. # check it's possible to overlap if it's allowed by the date range type
  69. self.type.allow_overlap = True
  70. dr = date_range.create({
  71. 'name': 'FS2016',
  72. 'date_start': '2015-01-01',
  73. 'date_end': '2016-12-31',
  74. 'type_id': self.type.id,
  75. })
  76. self.assertEqual(dr.name, 'FS2016')
  77. def test_domain(self):
  78. date_range = self.env['date.range']
  79. dr = date_range.create({
  80. 'name': 'FS2015',
  81. 'date_start': '2015-01-01',
  82. 'date_end': '2015-12-31',
  83. 'type_id': self.type.id,
  84. })
  85. domain = dr.get_domain('my_field')
  86. # By default the domain include limits
  87. self.assertEqual(
  88. domain,
  89. [('my_field', '>=', '2015-01-01'),
  90. ('my_field', '<=', '2015-12-31')])