Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TA#72215 [16.0] [MIG] timesheet_holidays_time_control_compatible #54

Open
wants to merge 10 commits into
base: 16.0
Choose a base branch
from
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"depends": [
"hr_timesheet_project_parent",
"project_timesheet_time_control_sheet",
"timesheet_holidays_time_control_binding",
],
"installable": True,
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ USER odoo

COPY hr_timesheet_project_parent /mnt/extra-addons/hr_timesheet_project_parent
COPY project_timesheet_time_control_sheet /mnt/extra-addons/project_timesheet_time_control_sheet
COPY timesheet_holidays_time_control_binding /mnt/extra-addons/timesheet_holidays_time_control_binding

COPY .docker_files/main /mnt/extra-addons/main
COPY .docker_files/odoo.conf /etc/odoo
1 change: 0 additions & 1 deletion gitoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
includes:
- web_ir_actions_act_multi
- web_widget_x2many_2d_matrix

21 changes: 21 additions & 0 deletions timesheet_holidays_time_control_binding/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Timesheet Holidays Time Control Binging
=======================================
This module makes the module `project_timesheet_time_control <https://github.com/OCA/project/tree/12.0/project_timesheet_time_control>`_ compatible with `project_timesheet_holidays`.

It allows to approve leave requests in advance while associating them with the date selected by the employee, rather than saving them on the validation date.

Usage
-----
As Leave Manager,
I validate leave for an employee requested for a later date,
Imputation on timesheets is made for the leave date and not the validation date

.. image:: static/description/leave_validated.png

The leave is charged to timesheets whose date is equivalent to the leave date and not the validation date.

.. image:: static/description/timesheets_from_leave.png

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
4 changes: 4 additions & 0 deletions timesheet_holidays_time_control_binding/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models

Check notice on line 4 in timesheet_holidays_time_control_binding/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

timesheet_holidays_time_control_binding/__init__.py#L4

'.models' imported but unused (F401)
16 changes: 16 additions & 0 deletions timesheet_holidays_time_control_binding/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{

Check warning on line 4 in timesheet_holidays_time_control_binding/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

timesheet_holidays_time_control_binding/__manifest__.py#L4

Statement seems to have no effect
"name": "Timesheet Holidays Time Control Binding",
"version": "16.0.1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "AGPL-3",
"category": "Project",
"depends": ["project_timesheet_holidays", "project_timesheet_time_control"],
"summary": "Confirm holiday with the holiday date not the validation date.",
"data": [],
"installable": True,
}
4 changes: 4 additions & 0 deletions timesheet_holidays_time_control_binding/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_leave

Check notice on line 4 in timesheet_holidays_time_control_binding/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

timesheet_holidays_time_control_binding/models/__init__.py#L4

'.hr_leave' imported but unused (F401)
20 changes: 20 additions & 0 deletions timesheet_holidays_time_control_binding/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import datetime

from odoo import models


class HrLeave(models.Model):
_inherit = "hr.leave"

def action_validate(self):
rivo2302 marked this conversation as resolved.
Show resolved Hide resolved
lanto-razafindrabe marked this conversation as resolved.
Show resolved Hide resolved
res = super().action_validate()
for holiday in self:
if holiday.timesheet_ids:
for timesheet_line in holiday.timesheet_ids:
timesheet_line.date_time = datetime.datetime.combine(
timesheet_line.date, datetime.time(8, 00)
)
return res
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions timesheet_holidays_time_control_binding/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_validate_holiday_date
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2023-today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields
from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon


class TestValidateHolidayDate(TestHrHolidaysCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()

def test_account_analytic_line_date(self):
leave_type = self.env["hr.leave.type"].create(
{
"name": "Paid Time Off",
"leave_validation_type": "hr",
}
)
allocation = (
self.env["hr.leave.allocation"]
.with_user(self.user_hruser_id)
.create(
{
"name": "30 days allocation",
"holiday_status_id": self.env.ref(
"hr_holidays.holiday_status_training"
).id,
"number_of_days": 30,
"employee_id": self.employee_emp_id,
}
)
)
allocation.action_validate()

# leave 1 only for 1 day or half
leave1 = (
self.env["hr.leave"]
.with_user(self.user_employee_id)
.create(
{
"name": "Holiday 1 Day",
"employee_id": self.employee_emp_id,
"holiday_status_id": leave_type.id,
"date_from": fields.Datetime.from_string("2023-09-20 08:00:00"),
"date_to": fields.Datetime.from_string("2023-09-20 17:00:00"),
"number_of_days": 1,
}
)
)
leave1.sudo().action_approve()

self.assertEqual(
leave1.sudo().timesheet_ids[0].date,
leave1.sudo().date_from.date(),
msg=None,
)

# leave 2 more than 1 day
date_start = fields.Datetime.from_string("2019-12-26 08:00:00")
date_end = fields.Datetime.from_string("2019-12-29 17:00:00")
leave2 = self.env["hr.leave"].create(
{
"name": "Holiday 3 Days",
"employee_id": self.employee_emp_id,
"holiday_status_id": leave_type.id,
"request_date_from": date_start,
"request_date_to": date_end,
"number_of_days": 2,
}
)
leave2.sudo().action_approve()

for timesheet_line in leave2.sudo().timesheet_ids:
self.assertIn(timesheet_line.date_time, [date_start, date_end])
Loading