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.

112 lines
3.9 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)nses/agpl).
  4. from odoo.tests.common import TransactionCase
  5. from odoo.exceptions import ValidationError
  6. from dateutil.rrule import MONTHLY
  7. class DateRangeGeneratorTest(TransactionCase):
  8. def setUp(self):
  9. super(DateRangeGeneratorTest, self).setUp()
  10. self.generator = self.env['date.range.generator']
  11. self.type = self.env['date.range.type'].create(
  12. {'name': 'Fiscal year',
  13. 'company_id': False,
  14. 'allow_overlap': False})
  15. self.company = self.env['res.company'].create({
  16. 'name': 'Test company',
  17. })
  18. self.company_2 = self.env['res.company'].create({
  19. 'name': 'Test company 2',
  20. 'parent_id': self.company.id,
  21. })
  22. self.typeB = self.env['date.range.type'].create(
  23. {'name': 'Fiscal year B',
  24. 'company_id': self.company.id,
  25. 'allow_overlap': False})
  26. def test_generate(self):
  27. generator = self.generator.create({
  28. 'date_start': '1943-01-01',
  29. 'name_prefix': '1943-',
  30. 'type_id': self.type.id,
  31. 'duration_count': 3,
  32. 'unit_of_time': MONTHLY,
  33. 'count': 4})
  34. generator.action_apply()
  35. ranges = self.env['date.range'].search(
  36. [('type_id', '=', self.type.id)])
  37. self.assertEquals(len(ranges), 4)
  38. range4 = ranges[3]
  39. self.assertEqual(range4.date_start, '1943-10-01')
  40. self.assertEqual(range4.date_end, '1943-12-31')
  41. self.assertEqual(range4.type_id, self.type)
  42. def test_generator_multicompany_1(self):
  43. generator = self.generator.new({
  44. 'date_start': '1943-01-01',
  45. 'name_prefix': '1943-',
  46. 'type_id': self.typeB.id,
  47. 'duration_count': 3,
  48. 'unit_of_time': MONTHLY,
  49. 'count': 4,
  50. 'company_id': self.company.id,
  51. })
  52. generator._cache.update(generator._convert_to_cache(
  53. {'company_id': self.company_2.id}, update=True))
  54. generator._onchange_company_id()
  55. self.assertFalse(generator.type_id)
  56. def test_generator_multicompany_2(self):
  57. with self.assertRaises(ValidationError):
  58. self.generator.create({
  59. 'date_start': '1943-01-01',
  60. 'name_prefix': '1943-',
  61. 'type_id': self.typeB.id,
  62. 'duration_count': 3,
  63. 'unit_of_time': MONTHLY,
  64. 'count': 4,
  65. 'company_id': self.company_2.id,
  66. })
  67. def test_generator_partner_id_domain(self):
  68. """Check here domain returned for partner_id
  69. in both date.range and date.range.generator"""
  70. date_range = self.env['date.range']
  71. generator = self.env['date.range.generator']
  72. date_type = self.env['date.range.type']
  73. month_type = date_type.create({
  74. 'name': 'month type'
  75. })
  76. day_type = date_type.create({
  77. 'name': 'day type',
  78. 'parent_type_id': month_type.id,
  79. })
  80. month_range = date_range.create({
  81. 'name': 'month range',
  82. 'type_id': month_type.id,
  83. 'date_start': '01-01-2050',
  84. 'date_end': '02-01-2050',
  85. })
  86. # now trigger onchange in generator,
  87. # which would also trigger onchange in date_range
  88. values = {
  89. 'date_start': month_range.date_start,
  90. 'type_id': day_type.id,
  91. }
  92. on_change = generator._onchange_spec()
  93. domain = generator.onchange(
  94. values,
  95. ['type_id', 'date_start'],
  96. on_change,
  97. )
  98. # check that with this search domain,
  99. # only the month_range record is returned.
  100. self.assertEqual(
  101. date_range.search(domain['domain']['parent_id']),
  102. month_range,
  103. )