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.

100 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. # -*- coding: utf-8 -*-
  2. # © 2016 ACSONE SA/NV (<http://acsone.eu>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
  4. from odoo.tests.common import TransactionCase
  5. from odoo.exceptions import ValidationError
  6. class DateRangeTest(TransactionCase):
  7. def setUp(self):
  8. super(DateRangeTest, self).setUp()
  9. self.type = self.env['date.range.type'].create(
  10. {'name': 'Fiscal year',
  11. 'company_id': False,
  12. 'allow_overlap': False})
  13. def test_default_company(self):
  14. date_range = self.env['date.range']
  15. dt = date_range.create({
  16. 'name': 'FS2016',
  17. 'date_start': '2015-01-01',
  18. 'date_end': '2016-12-31',
  19. 'type_id': self.type.id,
  20. })
  21. self.assertTrue(dt.company_id)
  22. # you can specify company_id to False
  23. dt = date_range.create({
  24. 'name': 'FS2016_NO_COMPANY',
  25. 'date_start': '2015-01-01',
  26. 'date_end': '2016-12-31',
  27. 'type_id': self.type.id,
  28. 'company_id': False
  29. })
  30. self.assertFalse(dt.company_id)
  31. def test_empty_company(self):
  32. date_range = self.env['date.range']
  33. dt = date_range.create({
  34. 'name': 'FS2016',
  35. 'date_start': '2015-01-01',
  36. 'date_end': '2016-12-31',
  37. 'type_id': self.type.id,
  38. 'company_id': None,
  39. })
  40. self.assertEqual(dt.name, 'FS2016')
  41. def test_invalid(self):
  42. date_range = self.env['date.range']
  43. with self.assertRaises(ValidationError) as cm:
  44. date_range.create({
  45. 'name': 'FS2016',
  46. 'date_end': '2015-01-01',
  47. 'date_start': '2016-12-31',
  48. 'type_id': self.type.id,
  49. })
  50. self.assertEqual(
  51. cm.exception.name,
  52. 'FS2016 is not a valid range (2016-12-31 > 2015-01-01)')
  53. def test_overlap(self):
  54. date_range = self.env['date.range']
  55. date_range.create({
  56. 'name': 'FS2015',
  57. 'date_start': '2015-01-01',
  58. 'date_end': '2015-12-31',
  59. 'type_id': self.type.id,
  60. })
  61. with self.assertRaises(ValidationError) as cm, self.env.cr.savepoint():
  62. date_range.create({
  63. 'name': 'FS2016',
  64. 'date_start': '2015-01-01',
  65. 'date_end': '2016-12-31',
  66. 'type_id': self.type.id,
  67. })
  68. self.assertEqual(cm.exception.name, 'FS2016 overlaps FS2015')
  69. # check it's possible to overlap if it's allowed by the date range type
  70. self.type.allow_overlap = True
  71. dr = date_range.create({
  72. 'name': 'FS2016',
  73. 'date_start': '2015-01-01',
  74. 'date_end': '2016-12-31',
  75. 'type_id': self.type.id,
  76. })
  77. self.assertEqual(dr.name, 'FS2016')
  78. def test_domain(self):
  79. date_range = self.env['date.range']
  80. dr = date_range.create({
  81. 'name': 'FS2015',
  82. 'date_start': '2015-01-01',
  83. 'date_end': '2015-12-31',
  84. 'type_id': self.type.id,
  85. })
  86. domain = dr.get_domain('my_field')
  87. # By default the domain include limits
  88. self.assertEqual(
  89. domain,
  90. [('my_field', '>=', '2015-01-01'),
  91. ('my_field', '<=', '2015-12-31')])