Purpose ======= Time Off : New Dashboard, Accruals feature, Public holidays, New time off type configuration view. - Review of Dashboard - Accrual feature : Currently, when you create an allocation, it's possible to create an Accrual, but there is no appraisal Plan. An Appraisal plan is use to define steps of accruals for each employee. In Belgium, we use accrual Allocation for European Leaves, or compensatory hours, it's a simple use case. But in USA, it's possible to change the calculation mode each year. Also, in USA, it's possible to deal your accrual plan when you arrive on the company. It's a HR Officer task to create the right Accrual allocation for each new employee. - Public Holidays : Improvement of global time off feature located on Working hours calendar. Now, Time off application have to manage Public Holidays. - Review of Time Off type configuration COM PR: https://github.com/odoo/odoo/pull/72511 ENT PR: https://github.com/odoo/enterprise/pull/19157 UPG PR: https://github.com/odoo/upgrade/pull/2791 TaskID:2475413 closes odoo/odoo#72511 Related: odoo/enterprise#19157 Related: odoo/upgrade#2791 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Co-authored-by: William Braeckman <wbr@odoo.com> Co-authored-by: Xavier BOL (xbo) <xbo@odoo.com> Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com> Co-authored-by: Yannick Tivisse <yti@odoo.com>
89 lines
4.3 KiB
Python
89 lines
4.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from datetime import datetime
|
|
from dateutil.relativedelta import relativedelta
|
|
|
|
from odoo.fields import Datetime
|
|
from odoo.addons.hr_work_entry_contract.tests.common import TestWorkEntryBase
|
|
|
|
|
|
class TestWorkEntryHolidaysBase(TestWorkEntryBase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestWorkEntryHolidaysBase, cls).setUpClass()
|
|
|
|
cls.leave_type = cls.env['hr.leave.type'].create({
|
|
'name': 'Legal Leaves',
|
|
'time_type': 'leave',
|
|
'requires_allocation': 'no',
|
|
'work_entry_type_id': cls.work_entry_type_leave.id
|
|
})
|
|
|
|
# I create a new employee "Jules"
|
|
cls.jules_emp = cls.env['hr.employee'].create({
|
|
'name': 'Jules',
|
|
'gender': 'male',
|
|
'birthday': '1984-05-01',
|
|
'country_id': cls.env.ref('base.be').id,
|
|
'department_id': cls.dep_rd.id,
|
|
})
|
|
|
|
cls.calendar_35h = cls.env['resource.calendar'].create({
|
|
'name': '35h calendar',
|
|
'attendance_ids': [
|
|
(0, 0, {'name': 'Monday Morning', 'dayofweek': '0', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
|
(0, 0, {'name': 'Monday Evening', 'dayofweek': '0', 'hour_from': 13, 'hour_to': 16, 'day_period': 'afternoon'}),
|
|
(0, 0, {'name': 'Tuesday Morning', 'dayofweek': '1', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
|
(0, 0, {'name': 'Tuesday Evening', 'dayofweek': '1', 'hour_from': 13, 'hour_to': 16, 'day_period': 'afternoon'}),
|
|
(0, 0, {'name': 'Wednesday Morning', 'dayofweek': '2', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
|
(0, 0, {'name': 'Wednesday Evening', 'dayofweek': '2', 'hour_from': 13, 'hour_to': 16, 'day_period': 'afternoon'}),
|
|
(0, 0, {'name': 'Thursday Morning', 'dayofweek': '3', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
|
(0, 0, {'name': 'Thursday Evening', 'dayofweek': '3', 'hour_from': 13, 'hour_to': 16, 'day_period': 'afternoon'}),
|
|
(0, 0, {'name': 'Friday Morning', 'dayofweek': '4', 'hour_from': 8, 'hour_to': 12, 'day_period': 'morning'}),
|
|
(0, 0, {'name': 'Friday Evening', 'dayofweek': '4', 'hour_from': 13, 'hour_to': 16, 'day_period': 'afternoon'})
|
|
]
|
|
})
|
|
cls.calendar_35h._onchange_hours_per_day() # update hours/day
|
|
cls.calendar_40h = cls.env['resource.calendar'].create({'name': 'Default calendar'})
|
|
|
|
# This contract ends at the 15th of the month
|
|
cls.contract_cdd = cls.env['hr.contract'].create({ # Fixed term contract
|
|
'date_end': datetime.strptime('2015-11-15', '%Y-%m-%d'),
|
|
'date_start': datetime.strptime('2015-01-01', '%Y-%m-%d'),
|
|
'name': 'First CDD Contract for Jules',
|
|
'resource_calendar_id': cls.calendar_40h.id,
|
|
'wage': 5000.0,
|
|
'employee_id': cls.jules_emp.id,
|
|
'state': 'open',
|
|
'kanban_state': 'blocked',
|
|
'date_generated_from': datetime.strptime('2015-11-16', '%Y-%m-%d'),
|
|
'date_generated_to': datetime.strptime('2015-11-16', '%Y-%m-%d'),
|
|
})
|
|
|
|
# This contract starts the next day
|
|
cls.contract_cdi = cls.env['hr.contract'].create({
|
|
'date_start': datetime.strptime('2015-11-16', '%Y-%m-%d'),
|
|
'name': 'Contract for Jules',
|
|
'resource_calendar_id': cls.calendar_35h.id,
|
|
'wage': 5000.0,
|
|
'employee_id': cls.jules_emp.id,
|
|
'state': 'open',
|
|
'kanban_state': 'normal',
|
|
'date_generated_from': datetime.strptime('2015-11-15', '%Y-%m-%d'),
|
|
'date_generated_to': datetime.strptime('2015-11-15', '%Y-%m-%d'),
|
|
})
|
|
|
|
@classmethod
|
|
def create_leave(cls, date_from=None, date_to=None):
|
|
date_from = date_from or Datetime.today()
|
|
date_to = date_to or Datetime.today() + relativedelta(days=1)
|
|
return cls.env['hr.leave'].create({
|
|
'name': 'Holiday !!!',
|
|
'employee_id': cls.richard_emp.id,
|
|
'holiday_status_id': cls.leave_type.id,
|
|
'date_to': date_to,
|
|
'date_from': date_from,
|
|
'number_of_days': 1,
|
|
})
|