This commit changes how hr_homeworking deals with hr.employee.homework records. Before this, an hr.employee.homework record was created for each day of the week, even if it was the default location of the employee. This commit reworks how homeworking deals with them to reduce the amount of records generated. Now default employee locations don't generate records. They are rendered in the calendar view as ghost events. For exceptions, we allow only creating a single exception per day. If an employee sets an exception as 'weekly', it sets that location as the default one for the employee on that day of the week. Not having to deal with recurrencies makes the homeworking code simpler to manage as well. Also exceptions are, by definition, not common. So we shouldn't expect a lot of exception records to be created. task-3527196 Part-of: odoo/odoo#137502
56 lines
1.9 KiB
Python
56 lines
1.9 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 TestHrHomeworkingCommon(common.TransactionCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(TestHrHomeworkingCommon, cls).setUpClass()
|
|
cls.env.user.tz = 'Europe/Brussels'
|
|
|
|
cls.user_employee = mail_new_test_user(cls.env, login='david', groups='base.group_user')
|
|
|
|
# Hr Data
|
|
Department = cls.env['hr.department'].with_context(tracking_disable=True)
|
|
WorkLocation = cls.env['hr.work.location'].with_context(tracking_disable=True)
|
|
main_partner_id = cls.env.ref('base.main_partner')
|
|
|
|
cls.rd_dept = Department.create({
|
|
'name': 'Research and devlopment',
|
|
})
|
|
|
|
cls.work_office_1 = WorkLocation.create({
|
|
'name': "Bureau 1",
|
|
'location_type': "office",
|
|
'address_id': main_partner_id.id,
|
|
})
|
|
|
|
cls.work_office_2 = WorkLocation.create({
|
|
'name': "Bureau 2",
|
|
'location_type': "office",
|
|
'address_id': main_partner_id.id,
|
|
})
|
|
|
|
cls.work_home = WorkLocation.create({
|
|
'name': "Maison",
|
|
'location_type': "home",
|
|
'address_id': main_partner_id.id,
|
|
})
|
|
|
|
cls.employee_emp = cls.env['hr.employee'].create({
|
|
'name': 'David Employee',
|
|
'user_id': cls.user_employee.id,
|
|
'department_id': cls.rd_dept.id,
|
|
'monday_location_id': cls.work_home.id,
|
|
'tuesday_location_id': cls.work_home.id,
|
|
'wednesday_location_id': cls.work_office_1.id,
|
|
'thursday_location_id': cls.work_office_1.id,
|
|
'friday_location_id': cls.work_office_1.id,
|
|
'saturday_location_id': cls.work_home.id,
|
|
'sunday_location_id': cls.work_home.id,
|
|
})
|