Skip to content

Commit

Permalink
[11.0][IMP] hr_holidays_compute_days: Add test context
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime Arroyo authored and OCA-git-bot committed Aug 27, 2019
1 parent df861d2 commit af90b6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions hr_holidays_compute_days/models/hr_holidays.py
Expand Up @@ -4,6 +4,7 @@
from odoo import api, fields, models
from datetime import time
from dateutil import tz
from odoo.tools import config


class HrHolidays(models.Model):
Expand Down Expand Up @@ -138,6 +139,10 @@ def _get_number_of_days(self, date_from, date_to, employee_id):
"""Pass context variable for including rest days or change passed dates
when computing full days.
"""
if (config['test_enable'] and
not self.env.context.get('test_full_days')):
return super()._get_number_of_days(date_from, date_to, employee_id)

obj = self.with_context(
include_rest_days=not self.holiday_status_id.exclude_rest_days,
)
Expand Down
4 changes: 3 additions & 1 deletion hr_holidays_compute_days/tests/test_holidays_compute_days.py
Expand Up @@ -11,7 +11,9 @@ class TestHolidaysComputeDaysBase(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestHolidaysComputeDaysBase, cls).setUpClass()
cls.HrHolidays = cls.env['hr.holidays']
cls.HrHolidays = cls.env['hr.holidays'].with_context(
test_full_days=True
)
cls.calendar = cls.env['resource.calendar'].create({
'name': 'Calendar',
})
Expand Down

0 comments on commit af90b6d

Please sign in to comment.