Files
odoo_source/addons/hr_holidays/tests/common.py
T
Philippe Wauthy 81c8a0564d [FIX] hr_holidays: round the number of days of a time off
When the user is set in another timezone than the context timezone, the first or last work interval retrieved to calculate the number of days
between two dates is starting later or ending earlier depending on the user timezone.
The number of days displayed between two dates is therefore not an integer.

e.g.
A time off taken between 08/06/2021 and 10/06/2021 (timezone in the context is Europe/Brussels) will give:
- Number of days: 3 days if the user is in Europe/Brussels
- Number of days: 2.69 if the user is in Asia/Calcutta (first work interval starting later)
- Number of days: 2.5 if the user is in US/Pacific (last work interval ending earlier)

task-2646655

closes odoo/odoo#77036

Related: odoo/upgrade#3486
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-05-09 15:01:08 +02:00

59 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.tests import common
class TestHrHolidaysCommon(common.TransactionCase):
@classmethod
def setUpClass(cls):
super(TestHrHolidaysCommon, cls).setUpClass()
cls.env.user.tz = 'Europe/Brussels'
# Test users to use through the various tests
cls.user_hruser = mail_new_test_user(cls.env, login='armande', groups='base.group_user,hr_holidays.group_hr_holidays_user')
cls.user_hruser_id = cls.user_hruser.id
cls.user_hrmanager = mail_new_test_user(cls.env, login='bastien', groups='base.group_user,hr_holidays.group_hr_holidays_manager')
cls.user_hrmanager_id = cls.user_hrmanager.id
cls.user_hrmanager.tz = 'Europe/Brussels'
cls.user_employee = mail_new_test_user(cls.env, login='david', groups='base.group_user')
cls.user_employee_id = cls.user_employee.id
# Hr Data
Department = cls.env['hr.department'].with_context(tracking_disable=True)
cls.hr_dept = Department.create({
'name': 'Human Resources',
})
cls.rd_dept = Department.create({
'name': 'Research and devlopment',
})
cls.employee_emp = cls.env['hr.employee'].create({
'name': 'David Employee',
'user_id': cls.user_employee_id,
'department_id': cls.rd_dept.id,
})
cls.employee_emp_id = cls.employee_emp.id
cls.employee_hruser = cls.env['hr.employee'].create({
'name': 'Armande HrUser',
'user_id': cls.user_hruser_id,
'department_id': cls.rd_dept.id,
})
cls.employee_hruser_id = cls.employee_hruser.id
cls.employee_hrmanager = cls.env['hr.employee'].create({
'name': 'Bastien HrManager',
'user_id': cls.user_hrmanager_id,
'department_id': cls.hr_dept.id,
'parent_id': cls.employee_hruser_id,
})
cls.employee_hrmanager_id = cls.employee_hrmanager.id
cls.rd_dept.write({'manager_id': cls.employee_hruser_id})