Browse Source
[11.0] resourece_calendar_schedule_iteration: add tests and some minor corrections
pull/1517/head
[11.0] resourece_calendar_schedule_iteration: add tests and some minor corrections
pull/1517/head
Lois Rilo
6 years ago
7 changed files with 104 additions and 43 deletions
-
19resource_calendar_schedule_iteration/README.rst
-
15resource_calendar_schedule_iteration/hooks.py
-
6resource_calendar_schedule_iteration/readme/CONTRIBUTORS.rst
-
5resource_calendar_schedule_iteration/readme/DESCRIPTION.rst
-
55resource_calendar_schedule_iteration/static/description/index.html
-
1resource_calendar_schedule_iteration/tests/__init__.py
-
46resource_calendar_schedule_iteration/tests/test_resource_calendar_schedule_iteration.py
@ -1,2 +1,4 @@ |
|||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> |
|||
(https://www.eficent.com) |
|||
* Eficent (https://www.eficent.com) |
|||
|
|||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> |
|||
* Lois Rilo Antelo <lois.rilo@eficent.com> |
@ -1,13 +1,10 @@ |
|||
When you want to plan a number of days in the past or in the future consiering |
|||
When you want to plan a number of days in the past or in the future considering |
|||
a working calendar, Odoo limits the number of days/hours that you can plan |
|||
ahead. |
|||
|
|||
In case that you want to plan days forward/backward, it currently restricts |
|||
to 100 iterations. |
|||
|
|||
In case that you want to plan hours forward/backward, it currently restricts |
|||
to 100 iterations. |
|||
|
|||
This module allows you to increase the iteration limit used in the resource |
|||
calendar to schedule days or hours by means of a system parameter defined |
|||
by the administrator. |
@ -0,0 +1 @@ |
|||
from . import test_resource_calendar_schedule_iteration |
@ -0,0 +1,46 @@ |
|||
# Copyright 2019 Eficent Business and IT Consulting Services S.L. |
|||
# (http://www.eficent.com) |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from datetime import datetime, timedelta |
|||
|
|||
import odoo.tests.common as common |
|||
|
|||
|
|||
class TestResourceCalendarScheduleIteration(common.TransactionCase): |
|||
|
|||
def setUp(self): |
|||
super(TestResourceCalendarScheduleIteration, self).setUp() |
|||
|
|||
self.icp = self.env['ir.config_parameter'] |
|||
|
|||
self.calendar = self.env.ref('resource.resource_calendar_std') |
|||
self.icp.set_param( |
|||
"resource.calendar.schedule.days.iteration.limit", 200) |
|||
|
|||
def test_01_days_iteration(self): |
|||
days = 150 |
|||
calendar_day = self.calendar.plan_days(-1 * days - 1, datetime.today()) |
|||
aprox_date = datetime.today() - timedelta(days=days) |
|||
# Without more iteration limit the date returned will be only 100 |
|||
# days back using calendar (default iteration limit) instead of 150. |
|||
self.assertLess(calendar_day, aprox_date) |
|||
|
|||
def test_02_hours_iteration(self): |
|||
hours = 1500 * 8 |
|||
hours_2 = 1700 * 8 |
|||
limit_hour = self.calendar.plan_hours(-1 * hours - 1, datetime.today()) |
|||
limit_hour_2 = self.calendar.plan_hours( |
|||
-1 * hours_2 - 1, datetime.today()) |
|||
# Both hour computation exceeded the limit so they should be the |
|||
# same (which is incorrect). |
|||
self.assertEqual(limit_hour, limit_hour_2) |
|||
self.icp.set_param( |
|||
"resource.calendar.schedule.hours.iteration.limit", 2000) |
|||
correct_hour = self.calendar.plan_hours( |
|||
-1 * hours - 1, datetime.today()) |
|||
correct_hour_2 = self.calendar.plan_hours( |
|||
-1 * hours_2 - 1, datetime.today()) |
|||
self.assertNotEqual(correct_hour, correct_hour_2) |
|||
self.assertLess(correct_hour, limit_hour) |
|||
self.assertLess(correct_hour_2, limit_hour_2) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue