-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] hr_holidays_public_work_location
- Loading branch information
1 parent
4bc5f0c
commit 004e9c6
Showing
17 changed files
with
903 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://github.com/OCA/hr-holidays/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 <https://github.com/OCA/hr-holidays/issues/new?body=module:%20hr_holidays_public_work_location%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `ForgeFlow <https://www.forgeflow.com>`_: | ||
|
||
* Laura Cazorla <[email protected]> | ||
|
||
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 <https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_public_work_location>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
36 changes: 36 additions & 0 deletions
36
hr_holidays_public_work_location/i18n/hr_holidays_public_work_location.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import hr_holidays_public | ||
from . import hr_leave |
72 changes: 72 additions & 0 deletions
72
hr_holidays_public_work_location/models/hr_holidays_public.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# 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, | ||
) | ||
partner = self._get_partner_deprecated_employee(partner_id, employee_id) | ||
employees = partner.employee_ids | ||
|
||
# In case of one partner with multiple employees, | ||
# we will consider a day as a holiday if at least one of the employees has that holiday | ||
if employees and employees.work_location_id: | ||
domain += [ | ||
"|", | ||
("work_location_ids", "=", False), | ||
("work_location_ids", "in", employees.work_location_id.ids), | ||
] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* `ForgeFlow <https://www.forgeflow.com>`_: | ||
|
||
* Laura Cazorla <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Oops, something went wrong.