diff --git a/hr_timesheet_overtime_rate_holidays/README.rst b/hr_timesheet_overtime_rate_holidays/README.rst new file mode 100644 index 0000000..b6952c3 --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/README.rst @@ -0,0 +1,70 @@ +=============================================== +Timesheet - Overtime and holidays compatibility +=============================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c66f9b84bace8273e5d1ae17aee636c58bb8bc63a2bc85c58efc080a59033467 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fcie--timesheet-lightgray.png?logo=github + :target: https://github.com/coopiteasy/cie-timesheet/tree/16.0/hr_timesheet_overtime_rate_holidays + :alt: coopiteasy/cie-timesheet + +|badge1| |badge2| |badge3| + +When timesheet lines are made from a holiday, they are never counted as overtime. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SC + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SC `_: + + * Carmen Bianca BAKKER + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-carmenbianca| image:: https://github.com/carmenbianca.png?size=40px + :target: https://github.com/carmenbianca + :alt: carmenbianca + +Current maintainer: + +|maintainer-carmenbianca| + +This module is part of the `coopiteasy/cie-timesheet `_ project on GitHub. + +You are welcome to contribute. diff --git a/hr_timesheet_overtime_rate_holidays/__init__.py b/hr_timesheet_overtime_rate_holidays/__init__.py new file mode 100644 index 0000000..3eb7887 --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import models diff --git a/hr_timesheet_overtime_rate_holidays/__manifest__.py b/hr_timesheet_overtime_rate_holidays/__manifest__.py new file mode 100644 index 0000000..56372b3 --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/__manifest__.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ + "name": "Timesheet - Overtime and holidays compatibility", + "summary": """ + When timesheet lines are made from a holiday, they are never counted + as overtime.""", + "version": "16.0.1.0.0", + "category": "Human Resources", + "website": "https://github.com/coopiteasy/cie-timesheet", + "author": "Coop IT Easy SC", + "maintainers": ["carmenbianca"], + "license": "AGPL-3", + "application": False, + "depends": [ + "project_timesheet_holidays", + "hr_timesheet_overtime_rate", + ], + # TODO: Should this be enabled? + # "auto_install": True, +} diff --git a/hr_timesheet_overtime_rate_holidays/models/__init__.py b/hr_timesheet_overtime_rate_holidays/models/__init__.py new file mode 100644 index 0000000..84f4adc --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/models/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import account_analytic_line diff --git a/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py b/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py new file mode 100644 index 0000000..22d378c --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import models + + +class AnalyticLine(models.Model): + _inherit = "account.analytic.line" + + def get_rate(self): + if self.holiday_id: + return 1 + return super().get_rate() diff --git a/hr_timesheet_overtime_rate_holidays/readme/CONTRIBUTORS.rst b/hr_timesheet_overtime_rate_holidays/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..f1ac675 --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Coop IT Easy SC `_: + + * Carmen Bianca BAKKER diff --git a/hr_timesheet_overtime_rate_holidays/readme/DESCRIPTION.rst b/hr_timesheet_overtime_rate_holidays/readme/DESCRIPTION.rst new file mode 100644 index 0000000..cfaadec --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +When timesheet lines are made from a holiday, they are never counted as overtime. diff --git a/hr_timesheet_overtime_rate_holidays/static/description/index.html b/hr_timesheet_overtime_rate_holidays/static/description/index.html new file mode 100644 index 0000000..d0df154 --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/static/description/index.html @@ -0,0 +1,421 @@ + + + + + +Timesheet - Overtime and holidays compatibility + + + +
+

Timesheet - Overtime and holidays compatibility

+ + +

Beta License: AGPL-3 coopiteasy/cie-timesheet

+

When timesheet lines are made from a holiday, they are never counted as overtime.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

Current maintainer:

+

carmenbianca

+

This module is part of the coopiteasy/cie-timesheet project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/hr_timesheet_overtime_rate_holidays/tests/__init__.py b/hr_timesheet_overtime_rate_holidays/tests/__init__.py new file mode 100644 index 0000000..e66310f --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/tests/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import test_timesheet_holidays diff --git a/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py b/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py new file mode 100644 index 0000000..e7eaa2b --- /dev/null +++ b/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2024 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + + +from datetime import datetime + +from dateutil.relativedelta import relativedelta + +from odoo.addons.hr_timesheet.tests.test_timesheet import TestCommonTimesheet + + +class TestTimesheetHolidays(TestCommonTimesheet): + def setUp(self): + super().setUp() + + self.leave_start_datetime = datetime(2018, 2, 5, 7, 0, 0, 0) # this is monday + self.leave_end_datetime = self.leave_start_datetime + relativedelta(days=3) + + self.internal_project = self.env.company.internal_project_id + self.internal_task_leaves = self.env.company.leave_timesheet_task_id + + self.hr_leave_type = self.env["hr.leave.type"].create( + { + "name": "Leave Type", + "requires_allocation": "no", + "timesheet_generate": True, + "timesheet_project_id": self.internal_project.id, + "timesheet_task_id": self.internal_task_leaves.id, + } + ) + + # I'm not sure what this record does in this context. + self.overtime = self.env["resource.overtime"].create({"name": "test"}) + self.rate = self.env["resource.overtime.rate"].create( + { + "name": "test", + "dayofweek": "0", # Monday + "rate": 2.0, + "overtime_id": self.overtime.id, + } + ) + + def test_unit_amount(self): + number_of_days = (self.leave_end_datetime - self.leave_start_datetime).days + holiday = ( + self.env["hr.leave"] + .with_user(self.user_employee) + .create( + { + "name": "Leave 1", + "employee_id": self.empl_employee.id, + "holiday_type": "employee", + "holiday_status_id": self.hr_leave_type.id, + "date_from": self.leave_start_datetime, + "date_to": self.leave_end_datetime, + "number_of_days": number_of_days, + } + ) + ) + holiday.sudo().action_validate() + + # This is the important bit. All the above is really annoying Odoo + # testing scaffolding. + analytic_lines = self.env["account.analytic.line"].search( + [ + ("date", ">=", self.leave_start_datetime.date()), + ("date", "<=", self.leave_end_datetime.date()), + ] + ) + self.assertEqual(len(analytic_lines), 3) + for line in analytic_lines: + self.assertAlmostEqual(line.unit_amount, 8.0) diff --git a/setup/hr_timesheet_overtime_rate_holidays/odoo/addons/hr_timesheet_overtime_rate_holidays b/setup/hr_timesheet_overtime_rate_holidays/odoo/addons/hr_timesheet_overtime_rate_holidays new file mode 120000 index 0000000..bc2b632 --- /dev/null +++ b/setup/hr_timesheet_overtime_rate_holidays/odoo/addons/hr_timesheet_overtime_rate_holidays @@ -0,0 +1 @@ +../../../../hr_timesheet_overtime_rate_holidays \ No newline at end of file diff --git a/setup/hr_timesheet_overtime_rate_holidays/setup.py b/setup/hr_timesheet_overtime_rate_holidays/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/hr_timesheet_overtime_rate_holidays/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)