From c6fd96624f48c2c2a087a6c369b0f837db3f0732 Mon Sep 17 00:00:00 2001 From: LauraCForgeFlow Date: Tue, 28 Jan 2025 09:13:25 +0100 Subject: [PATCH 1/4] [ADD] hr_holidays_public_work_location --- hr_holidays_public_work_location/README.rst | 85 ++++ hr_holidays_public_work_location/__init__.py | 1 + .../__manifest__.py | 15 + hr_holidays_public_work_location/i18n/es.po | 36 ++ .../i18n/hr_holidays_public_work_location.pot | 36 ++ .../models/__init__.py | 2 + .../models/hr_holidays_public.py | 73 +++ .../models/hr_leave.py | 31 ++ .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 8 + .../static/description/index.html | 432 ++++++++++++++++++ .../tests/__init__.py | 2 + .../tests/test_holidays_calculation.py | 24 + .../tests/test_holidays_public.py | 132 ++++++ .../views/hr_holidays_public_view.xml | 17 + 15 files changed, 897 insertions(+) create mode 100644 hr_holidays_public_work_location/README.rst create mode 100644 hr_holidays_public_work_location/__init__.py create mode 100644 hr_holidays_public_work_location/__manifest__.py create mode 100644 hr_holidays_public_work_location/i18n/es.po create mode 100644 hr_holidays_public_work_location/i18n/hr_holidays_public_work_location.pot create mode 100644 hr_holidays_public_work_location/models/__init__.py create mode 100644 hr_holidays_public_work_location/models/hr_holidays_public.py create mode 100644 hr_holidays_public_work_location/models/hr_leave.py create mode 100644 hr_holidays_public_work_location/readme/CONTRIBUTORS.rst create mode 100644 hr_holidays_public_work_location/readme/DESCRIPTION.rst create mode 100644 hr_holidays_public_work_location/static/description/index.html create mode 100644 hr_holidays_public_work_location/tests/__init__.py create mode 100644 hr_holidays_public_work_location/tests/test_holidays_calculation.py create mode 100644 hr_holidays_public_work_location/tests/test_holidays_public.py create mode 100644 hr_holidays_public_work_location/views/hr_holidays_public_view.xml diff --git a/hr_holidays_public_work_location/README.rst b/hr_holidays_public_work_location/README.rst new file mode 100644 index 00000000..6b831a8c --- /dev/null +++ b/hr_holidays_public_work_location/README.rst @@ -0,0 +1,85 @@ +================================ +HR Holidays Public Work Location +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:aea1c264c034f69c3f02bb0cd26bc835b1b9fea45ae518dd0eddf8e448fa7c2b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fhr--holidays-lightgray.png?logo=github + :target: https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_public_work_location + :alt: OCA/hr-holidays +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_public_work_location + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the work location of employees at the public vacation line +level as an extra discriminant. That way, we can have some public vacations +that are only valid for employees working in a specific location, even when +there are more locations in the same country or state. + +The chosen work locations must belong to the public vacation's country, as well +as public vacation line's state, if any. That information is stored in the work +location's address. + +**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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* `ForgeFlow `_: + + * Laura Cazorla + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/hr-holidays `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_holidays_public_work_location/__init__.py b/hr_holidays_public_work_location/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/hr_holidays_public_work_location/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_holidays_public_work_location/__manifest__.py b/hr_holidays_public_work_location/__manifest__.py new file mode 100644 index 00000000..a9edcedc --- /dev/null +++ b/hr_holidays_public_work_location/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "HR Holidays Public Work Location", + "version": "16.0.1.0.0", + "category": "Tools", + "website": "https://github.com/OCA/hr-holidays", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["hr_holidays_public"], + "data": ["views/hr_holidays_public_view.xml"], + "installable": True, + "application": False, +} diff --git a/hr_holidays_public_work_location/i18n/es.po b/hr_holidays_public_work_location/i18n/es.po new file mode 100644 index 00000000..bc413f1f --- /dev/null +++ b/hr_holidays_public_work_location/i18n/es.po @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_holidays_public_work_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-28 07:54+0000\n" +"PO-Revision-Date: 2025-01-28 07:54+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_holidays_public +msgid "Public Holidays" +msgstr "Festivos" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_holidays_public_line +msgid "Public Holidays Lines" +msgstr "Líneas de Festivos" + +#. module: hr_holidays_public_work_location +#: model:ir.model.fields,field_description:hr_holidays_public_work_location.field_hr_holidays_public_line__work_location_ids +msgid "Related Work Locations" +msgstr "Ubicaciones de Trabajo Relacionadas" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_leave +msgid "Time Off" +msgstr "Ausencias" diff --git a/hr_holidays_public_work_location/i18n/hr_holidays_public_work_location.pot b/hr_holidays_public_work_location/i18n/hr_holidays_public_work_location.pot new file mode 100644 index 00000000..614e3d08 --- /dev/null +++ b/hr_holidays_public_work_location/i18n/hr_holidays_public_work_location.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_holidays_public_work_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-01-28 07:53+0000\n" +"PO-Revision-Date: 2025-01-28 07:53+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_holidays_public +msgid "Public Holidays" +msgstr "" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_holidays_public_line +msgid "Public Holidays Lines" +msgstr "" + +#. module: hr_holidays_public_work_location +#: model:ir.model.fields,field_description:hr_holidays_public_work_location.field_hr_holidays_public_line__work_location_ids +msgid "Related Work Locations" +msgstr "" + +#. module: hr_holidays_public_work_location +#: model:ir.model,name:hr_holidays_public_work_location.model_hr_leave +msgid "Time Off" +msgstr "" diff --git a/hr_holidays_public_work_location/models/__init__.py b/hr_holidays_public_work_location/models/__init__.py new file mode 100644 index 00000000..fba3743d --- /dev/null +++ b/hr_holidays_public_work_location/models/__init__.py @@ -0,0 +1,2 @@ +from . import hr_holidays_public +from . import hr_leave diff --git a/hr_holidays_public_work_location/models/hr_holidays_public.py b/hr_holidays_public_work_location/models/hr_holidays_public.py new file mode 100644 index 00000000..898c3513 --- /dev/null +++ b/hr_holidays_public_work_location/models/hr_holidays_public.py @@ -0,0 +1,73 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class HrHolidaysPublic(models.Model): + _inherit = "hr.holidays.public" + + def _get_domain_states_filter( + self, pholidays, start_dt, end_dt, employee_id=None, partner_id=None + ): + domain = super()._get_domain_states_filter( + pholidays=pholidays, + start_dt=start_dt, + end_dt=end_dt, + employee_id=employee_id, + partner_id=partner_id, + ) + # To check for holidays in work locations, we must use the employee's + # information instead of the partner's information + employee_id = employee_id or self.env.context.get("employee_id", False) + employee = self.env["hr.employee"].browse(employee_id) if employee_id else False + # We check if the employee has a work location set, and we add that + # restriction to the domain + if employee and employee.work_location_id: + domain += [ + "|", + ("work_location_ids", "=", False), + ("work_location_ids", "=", employee.work_location_id.id), + ] + else: + domain.append(("work_location_ids", "=", False)) + return domain + + +class HrHolidaysPublicLine(models.Model): + _inherit = "hr.holidays.public.line" + + work_location_ids = fields.Many2many( + "hr.work.location", + "hr_holiday_public_work_location_rel", + "line_id", + "work_location_id", + "Related Work Locations", + ) + + @api.constrains("work_location_ids") + def _check_date_state_work_location_ids(self): + self._check_date_state() + + @api.constrains("work_location_ids") + def _update_calendar_event_work_location_ids(self): + self._update_calendar_event() + + def _get_domain_check_date_state_one_state_ids(self): + domain = super()._get_domain_check_date_state_one_state_ids() + if self.work_location_ids: + domain += [("work_location_ids", "!=", False)] + return domain + + def _get_domain_check_date_state_one(self): + domain = super()._get_domain_check_date_state_one() + domain += [("work_location_ids", "=", False)] + return domain + + def _prepare_holidays_meeting_values(self): + res = super()._prepare_holidays_meeting_values() + if self.work_location_ids: + res["description"] += ": " + ", ".join( + self.work_location_ids.mapped("name") + ) + return res diff --git a/hr_holidays_public_work_location/models/hr_leave.py b/hr_holidays_public_work_location/models/hr_leave.py new file mode 100644 index 00000000..16392f3d --- /dev/null +++ b/hr_holidays_public_work_location/models/hr_leave.py @@ -0,0 +1,31 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class HrLeave(models.Model): + _inherit = "hr.leave" + + def _get_domain_from_get_unusual_days(self, date_from, date_to=None): + domain = super()._get_domain_from_get_unusual_days( + date_from=date_from, date_to=date_to + ) + # Use the employee of the user or the one who has the context + employee_id = self.env.context.get("employee_id", False) + employee = ( + self.env["hr.employee"].browse(employee_id) + if employee_id + else self.env.user.employee_id + ) + # Add work location domain + work_location = employee.work_location_id.id + if work_location: + domain.extend( + [ + "|", + ("work_location_ids", "=", work_location), + ("work_location_ids", "=", False), + ] + ) + return domain diff --git a/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst b/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..5689de76 --- /dev/null +++ b/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `ForgeFlow `_: + + * Laura Cazorla diff --git a/hr_holidays_public_work_location/readme/DESCRIPTION.rst b/hr_holidays_public_work_location/readme/DESCRIPTION.rst new file mode 100644 index 00000000..d3dff676 --- /dev/null +++ b/hr_holidays_public_work_location/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +This module adds the work location of employees at the public vacation line +level as an extra discriminant. That way, we can have some public vacations +that are only valid for employees working in a specific location, even when +there are more locations in the same country or state. + +The chosen work locations must belong to the public vacation's country, as well +as public vacation line's state, if any. That information is stored in the work +location's address. diff --git a/hr_holidays_public_work_location/static/description/index.html b/hr_holidays_public_work_location/static/description/index.html new file mode 100644 index 00000000..c26375af --- /dev/null +++ b/hr_holidays_public_work_location/static/description/index.html @@ -0,0 +1,432 @@ + + + + + +HR Holidays Public Work Location + + + +
+

HR Holidays Public Work Location

+ + +

Beta License: AGPL-3 OCA/hr-holidays Translate me on Weblate Try me on Runboat

+

This module adds the work location of employees at the public vacation line +level as an extra discriminant. That way, we can have some public vacations +that are only valid for employees working in a specific location, even when +there are more locations in the same country or state.

+

The chosen work locations must belong to the public vacation’s country, as well +as public vacation line’s state, if any. That information is stored in the work +location’s address.

+

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

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/hr-holidays project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_holidays_public_work_location/tests/__init__.py b/hr_holidays_public_work_location/tests/__init__.py new file mode 100644 index 00000000..8b16ef2e --- /dev/null +++ b/hr_holidays_public_work_location/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_holidays_calculation +from . import test_holidays_public diff --git a/hr_holidays_public_work_location/tests/test_holidays_calculation.py b/hr_holidays_public_work_location/tests/test_holidays_calculation.py new file mode 100644 index 00000000..1cbc6db0 --- /dev/null +++ b/hr_holidays_public_work_location/tests/test_holidays_calculation.py @@ -0,0 +1,24 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.addons.hr_holidays_public.tests import test_holidays_calculation + + +class TestHolidaysComputeDays(test_holidays_calculation.TestHolidaysComputeDays): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.work_location_model = cls.env["hr.work.location"] + cls.work_location_a = cls.work_location_model.create( + { + "name": "Work Location A (ES)", + "address_id": cls.address_2.id, + } + ) + + cls.employee_1.write({"address_home_id": cls.address_1.id}) + cls.employee_2.write({"address_home_id": cls.address_2.id}) + cls.employee_2.write({"work_location_id": cls.work_location_a.id}) + cls.public_holiday_country.line_ids.work_location_ids = cls.work_location_a.ids + + # Run all tests of hr_holidays_public diff --git a/hr_holidays_public_work_location/tests/test_holidays_public.py b/hr_holidays_public_work_location/tests/test_holidays_public.py new file mode 100644 index 00000000..a8c759b8 --- /dev/null +++ b/hr_holidays_public_work_location/tests/test_holidays_public.py @@ -0,0 +1,132 @@ +# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.addons.hr_holidays_public.tests import test_holidays_public + + +class TestHolidaysPublicBase(test_holidays_public.TestHolidaysPublicBase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.work_location_model = cls.env["hr.work.location"] + cls.work_location_a = cls.work_location_model.create( + { + "name": "Work Location A (US)", + "address_id": cls.env.company.partner_id.id, + } + ) + cls.work_location_b = cls.work_location_model.create( + { + "name": "Work Location B (US)", + "address_id": cls.env.company.partner_id.id, + } + ) + + +class TestHolidaysPublic(TestHolidaysPublicBase): + def assertPublicHolidayIsUnusualDay( + self, expected, country_id=None, state_ids=False, work_location_ids=False + ): + self.assertFalse( + self.leave_model.with_user(self.env.ref("base.user_demo").id) + .get_unusual_days("2019-07-01", date_to="2019-07-31") + .get("2019-07-30", False) + ) + holiday = self.holiday_model.create({"year": 2019, "country_id": country_id}) + self.holiday_model_line.create( + { + "name": "holiday x", + "date": "2019-07-30", + "year_id": holiday.id, + "state_ids": state_ids, + "work_location_ids": work_location_ids, + } + ) + self.assertEqual( + self.leave_model.with_user( + self.env.ref("base.user_demo").id + ).get_unusual_days("2019-07-01", date_to="2019-07-31")["2019-07-30"], + expected, + ) + + def test_public_holidays_context(self): + self.env.ref("base.user_demo").employee_id.address_id.country_id = False + self.env.ref("base.user_demo").employee_id.address_id.state_id = False + self.env.ref("base.user_demo").employee_id.work_location_id = False + self.employee.address_id.country_id = self.env.ref("base.us") + self.employee.address_id.state_id = self.env.ref("base.state_us_4") + self.employee.work_location_id = self.work_location_a + + self.leave_model = self.leave_model.with_context(employee_id=self.employee.id) + self.assertPublicHolidayIsUnusualDay( + True, + country_id=self.env.ref( + "base.user_demo" + ).employee_id.address_id.country_id.id, + state_ids=[(6, 0, [self.employee.address_id.state_id.id])], + work_location_ids=[(6, 0, [self.employee.work_location_id.id])], + ) + + def test_get_unusual_days_return_public_holidays_same_state_same_work_location( + self, + ): + demo_user_empl_addr = self.env.ref("base.user_demo").employee_id.address_id + demo_user_empl = self.env.ref("base.user_demo").employee_id + demo_user_empl_addr.country_id = self.env.ref("base.us") + demo_user_empl_addr.state_id = self.env.ref("base.state_us_4") + demo_user_empl.work_location_id = self.work_location_a + self.assertPublicHolidayIsUnusualDay( + True, + country_id=self.env.ref( + "base.user_demo" + ).employee_id.address_id.country_id.id, + state_ids=[(6, 0, [demo_user_empl_addr.state_id.id])], + work_location_ids=[(6, 0, [demo_user_empl.work_location_id.id])], + ) + + def test_get_unusual_days_return_public_holidays_same_state_different_work_location( + self, + ): + demo_user_empl_addr = self.env.ref("base.user_demo").employee_id.address_id + demo_user_empl = self.env.ref("base.user_demo").employee_id + demo_user_empl_addr.country_id = self.env.ref("base.us") + demo_user_empl_addr.state_id = self.env.ref("base.state_us_4") + demo_user_empl.work_location_id = self.work_location_a + self.assertPublicHolidayIsUnusualDay( + False, + country_id=self.env.ref( + "base.user_demo" + ).employee_id.address_id.country_id.id, + state_ids=[(6, 0, [demo_user_empl_addr.state_id.id])], + work_location_ids=[(6, 0, [self.work_location_b.id])], + ) + + def test_get_unusual_days_return_public_holidays_no_state_same_work_location(self): + demo_user_empl_addr = self.env.ref("base.user_demo").employee_id.address_id + demo_user_empl = self.env.ref("base.user_demo").employee_id + demo_user_empl_addr.country_id = self.env.ref("base.us") + demo_user_empl_addr.state_id = self.env.ref("base.state_us_4") + demo_user_empl.work_location_id = self.work_location_a + self.assertPublicHolidayIsUnusualDay( + True, + country_id=self.env.ref( + "base.user_demo" + ).employee_id.address_id.country_id.id, + work_location_ids=[(6, 0, [demo_user_empl.work_location_id.id])], + ) + + def test_get_unusual_days_return_public_holidays_no_state_different_work_location( + self, + ): + demo_user_empl_addr = self.env.ref("base.user_demo").employee_id.address_id + demo_user_empl = self.env.ref("base.user_demo").employee_id + demo_user_empl_addr.country_id = self.env.ref("base.us") + demo_user_empl_addr.state_id = self.env.ref("base.state_us_4") + demo_user_empl.work_location_id = self.work_location_a + self.assertPublicHolidayIsUnusualDay( + True, + country_id=self.env.ref( + "base.user_demo" + ).employee_id.address_id.country_id.id, + work_location_ids=[(6, 0, [demo_user_empl.work_location_id.id])], + ) diff --git a/hr_holidays_public_work_location/views/hr_holidays_public_view.xml b/hr_holidays_public_work_location/views/hr_holidays_public_view.xml new file mode 100644 index 00000000..d0fc17c2 --- /dev/null +++ b/hr_holidays_public_work_location/views/hr_holidays_public_view.xml @@ -0,0 +1,17 @@ + + + + hr.holidays.public.form + hr.holidays.public + + + + + + + + From 1d6b34ac96a2e28a5428457145b51c9fc015b30f Mon Sep 17 00:00:00 2001 From: ArnauCForgeFlow Date: Wed, 26 Feb 2025 08:23:57 +0100 Subject: [PATCH 2/4] [IMP] hr_holidays_public_work_location: pre-commit auto fixes --- hr_holidays_public_work_location/README.rst | 35 ++++++++++--------- .../pyproject.toml | 3 ++ .../readme/CONTRIBUTORS.md | 2 ++ .../readme/CONTRIBUTORS.rst | 3 -- .../readme/DESCRIPTION.md | 9 +++++ .../readme/DESCRIPTION.rst | 8 ----- .../static/description/index.html | 21 +++++------ 7 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 hr_holidays_public_work_location/pyproject.toml create mode 100644 hr_holidays_public_work_location/readme/CONTRIBUTORS.md delete mode 100644 hr_holidays_public_work_location/readme/CONTRIBUTORS.rst create mode 100644 hr_holidays_public_work_location/readme/DESCRIPTION.md delete mode 100644 hr_holidays_public_work_location/readme/DESCRIPTION.rst diff --git a/hr_holidays_public_work_location/README.rst b/hr_holidays_public_work_location/README.rst index 6b831a8c..6c950aa0 100644 --- a/hr_holidays_public_work_location/README.rst +++ b/hr_holidays_public_work_location/README.rst @@ -17,25 +17,26 @@ HR Holidays Public Work Location :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github - :target: https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_public_work_location + :target: https://github.com/OCA/hr-holidays/tree/18.0/hr_holidays_public_work_location :alt: OCA/hr-holidays .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_public_work_location + :target: https://translation.odoo-community.org/projects/hr-holidays-18-0/hr-holidays-18-0-hr_holidays_public_work_location :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module adds the work location of employees at the public vacation line -level as an extra discriminant. That way, we can have some public vacations -that are only valid for employees working in a specific location, even when -there are more locations in the same country or state. +This module adds the work location of employees at the public vacation +line level as an extra discriminant. That way, we can have some public +vacations that are only valid for employees working in a specific +location, even when there are more locations in the same country or +state. -The chosen work locations must belong to the public vacation's country, as well -as public vacation line's state, if any. That information is stored in the work -location's address. +The chosen work locations must belong to the public vacation's country, +as well as public vacation line's state, if any. That information is +stored in the work location's address. **Table of contents** @@ -48,7 +49,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -56,19 +57,19 @@ Credits ======= Authors -~~~~~~~ +------- * ForgeFlow Contributors -~~~~~~~~~~~~ +------------ -* `ForgeFlow `_: +- `ForgeFlow `__: - * Laura Cazorla + - Laura Cazorla Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -80,6 +81,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/hr-holidays `_ project on GitHub. +This module is part of the `OCA/hr-holidays `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_holidays_public_work_location/pyproject.toml b/hr_holidays_public_work_location/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/hr_holidays_public_work_location/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_holidays_public_work_location/readme/CONTRIBUTORS.md b/hr_holidays_public_work_location/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..d2b41b50 --- /dev/null +++ b/hr_holidays_public_work_location/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [ForgeFlow](https://www.forgeflow.com): + - Laura Cazorla \<\> diff --git a/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst b/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst deleted file mode 100644 index 5689de76..00000000 --- a/hr_holidays_public_work_location/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,3 +0,0 @@ -* `ForgeFlow `_: - - * Laura Cazorla diff --git a/hr_holidays_public_work_location/readme/DESCRIPTION.md b/hr_holidays_public_work_location/readme/DESCRIPTION.md new file mode 100644 index 00000000..f6aa8870 --- /dev/null +++ b/hr_holidays_public_work_location/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +This module adds the work location of employees at the public vacation +line level as an extra discriminant. That way, we can have some public +vacations that are only valid for employees working in a specific +location, even when there are more locations in the same country or +state. + +The chosen work locations must belong to the public vacation's country, +as well as public vacation line's state, if any. That information is +stored in the work location's address. diff --git a/hr_holidays_public_work_location/readme/DESCRIPTION.rst b/hr_holidays_public_work_location/readme/DESCRIPTION.rst deleted file mode 100644 index d3dff676..00000000 --- a/hr_holidays_public_work_location/readme/DESCRIPTION.rst +++ /dev/null @@ -1,8 +0,0 @@ -This module adds the work location of employees at the public vacation line -level as an extra discriminant. That way, we can have some public vacations -that are only valid for employees working in a specific location, even when -there are more locations in the same country or state. - -The chosen work locations must belong to the public vacation's country, as well -as public vacation line's state, if any. That information is stored in the work -location's address. diff --git a/hr_holidays_public_work_location/static/description/index.html b/hr_holidays_public_work_location/static/description/index.html index c26375af..1635fb76 100644 --- a/hr_holidays_public_work_location/static/description/index.html +++ b/hr_holidays_public_work_location/static/description/index.html @@ -369,14 +369,15 @@

HR Holidays Public Work Location

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:aea1c264c034f69c3f02bb0cd26bc835b1b9fea45ae518dd0eddf8e448fa7c2b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/hr-holidays Translate me on Weblate Try me on Runboat

-

This module adds the work location of employees at the public vacation line -level as an extra discriminant. That way, we can have some public vacations -that are only valid for employees working in a specific location, even when -there are more locations in the same country or state.

-

The chosen work locations must belong to the public vacation’s country, as well -as public vacation line’s state, if any. That information is stored in the work -location’s address.

+

Beta License: AGPL-3 OCA/hr-holidays Translate me on Weblate Try me on Runboat

+

This module adds the work location of employees at the public vacation +line level as an extra discriminant. That way, we can have some public +vacations that are only valid for employees working in a specific +location, even when there are more locations in the same country or +state.

+

The chosen work locations must belong to the public vacation’s country, +as well as public vacation line’s state, if any. That information is +stored in the work location’s address.

Table of contents

    @@ -394,7 +395,7 @@

    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.

    +feedback.

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

@@ -423,7 +424,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/hr-holidays project on GitHub.

+

This module is part of the OCA/hr-holidays project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From 35cec982815c2daddfaf0f48c24c37d129561579 Mon Sep 17 00:00:00 2001 From: ArnauCForgeFlow Date: Wed, 26 Feb 2025 12:46:57 +0100 Subject: [PATCH 3/4] [MIG] hr_holidays_public_work_location: Migration to 18.0 --- hr_holidays_public_work_location/__manifest__.py | 2 +- .../models/hr_holidays_public.py | 13 +++++-------- .../tests/test_holidays_public.py | 5 +++-- .../views/hr_holidays_public_view.xml | 9 ++++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hr_holidays_public_work_location/__manifest__.py b/hr_holidays_public_work_location/__manifest__.py index a9edcedc..d8e9d700 100644 --- a/hr_holidays_public_work_location/__manifest__.py +++ b/hr_holidays_public_work_location/__manifest__.py @@ -3,7 +3,7 @@ { "name": "HR Holidays Public Work Location", - "version": "16.0.1.0.0", + "version": "18.0.1.0.0", "category": "Tools", "website": "https://github.com/OCA/hr-holidays", "author": "ForgeFlow, Odoo Community Association (OCA)", diff --git a/hr_holidays_public_work_location/models/hr_holidays_public.py b/hr_holidays_public_work_location/models/hr_holidays_public.py index 898c3513..12f4c074 100644 --- a/hr_holidays_public_work_location/models/hr_holidays_public.py +++ b/hr_holidays_public_work_location/models/hr_holidays_public.py @@ -4,22 +4,19 @@ from odoo import api, fields, models -class HrHolidaysPublic(models.Model): - _inherit = "hr.holidays.public" +class CalendarPublicHoliday(models.Model): + _inherit = "calendar.public.holiday" - def _get_domain_states_filter( - self, pholidays, start_dt, end_dt, employee_id=None, partner_id=None - ): + def _get_domain_states_filter(self, pholidays, start_dt, end_dt, partner_id=None): domain = super()._get_domain_states_filter( pholidays=pholidays, start_dt=start_dt, end_dt=end_dt, - employee_id=employee_id, partner_id=partner_id, ) # To check for holidays in work locations, we must use the employee's # information instead of the partner's information - employee_id = employee_id or self.env.context.get("employee_id", False) + employee_id = self.env.context.get("employee_id", False) employee = self.env["hr.employee"].browse(employee_id) if employee_id else False # We check if the employee has a work location set, and we add that # restriction to the domain @@ -35,7 +32,7 @@ def _get_domain_states_filter( class HrHolidaysPublicLine(models.Model): - _inherit = "hr.holidays.public.line" + _inherit = "calendar.public.holiday.line" work_location_ids = fields.Many2many( "hr.work.location", diff --git a/hr_holidays_public_work_location/tests/test_holidays_public.py b/hr_holidays_public_work_location/tests/test_holidays_public.py index a8c759b8..9e1a608f 100644 --- a/hr_holidays_public_work_location/tests/test_holidays_public.py +++ b/hr_holidays_public_work_location/tests/test_holidays_public.py @@ -4,10 +4,11 @@ from odoo.addons.hr_holidays_public.tests import test_holidays_public -class TestHolidaysPublicBase(test_holidays_public.TestHolidaysPublicBase): +class TestHolidaysPublicBase(test_holidays_public.TestHolidaysPublic): @classmethod def setUpClass(cls): super().setUpClass() + cls.holiday_model_line = cls.env["calendar.public.holiday.line"] cls.work_location_model = cls.env["hr.work.location"] cls.work_location_a = cls.work_location_model.create( { @@ -37,7 +38,7 @@ def assertPublicHolidayIsUnusualDay( { "name": "holiday x", "date": "2019-07-30", - "year_id": holiday.id, + "public_holiday_id": holiday.id, "state_ids": state_ids, "work_location_ids": work_location_ids, } diff --git a/hr_holidays_public_work_location/views/hr_holidays_public_view.xml b/hr_holidays_public_work_location/views/hr_holidays_public_view.xml index d0fc17c2..db5feb47 100644 --- a/hr_holidays_public_work_location/views/hr_holidays_public_view.xml +++ b/hr_holidays_public_work_location/views/hr_holidays_public_view.xml @@ -1,9 +1,12 @@ - hr.holidays.public.form - hr.holidays.public - + calendar.public.holiday.form + calendar.public.holiday + Date: Wed, 26 Feb 2025 12:53:57 +0100 Subject: [PATCH 4/4] [DON'T MERGE] test-requirements.txt --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..7a496c81 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-hr_holidays_public @ git+https://github.com/OCA/hr-holidays.git@refs/pull/159/head#subdirectory=hr_holidays_public