Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions hr_holidays_public_city/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=======================
HR Holidays Public City
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5f936bdf53ab4a15cf0b735495ac3e0306aedfb9d60cc3a47f869d5060851072
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.0/hr_holidays_public_city
: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-19-0/hr-holidays-19-0-hr_holidays_public_city
: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=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds the cities at the public vacation line level as an
extra discriminant.

**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_city%0Aversion:%2019.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
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__

- Pedro M. Baeza
- Víctor Martínez

- `APSL <https://apsl.tech>`__:

- Antoni Marroig <amarroig@apsl.net>

- `Niboo <https://www.niboo.com>`__:

- Simon Falesse

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.

.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/hr-holidays <https://github.com/OCA/hr-holidays/tree/19.0/hr_holidays_public_city>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_holidays_public_city/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions hr_holidays_public_city/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "HR Holidays Public City",
"version": "19.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/hr-holidays",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["hr_holidays_public", "base_address_extended"],
"data": [
"views/calendar_public_holiday_view.xml",
],
"installable": True,
"maintainers": ["victoralmau"],
}
3 changes: 3 additions & 0 deletions hr_holidays_public_city/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import calendar_public_holiday
from . import calendar_public_holiday_line
from . import hr_leave
24 changes: 24 additions & 0 deletions hr_holidays_public_city/models/calendar_public_holiday.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2026 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import models


class ResourceCalendarPublicHoliday(models.Model):
_inherit = "calendar.public.holiday"

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, partner_id=partner_id
)
partner = partner_model = self.env["res.partner"]
if partner_id:
partner = partner_model.browse(partner_id)
if partner and partner.city_id:
domain += [
"|",
("city_ids", "=", False),
("city_ids", "=", partner.city_id.id),
]
else:
domain.append(("city_ids", "=", False))
return domain
40 changes: 40 additions & 0 deletions hr_holidays_public_city/models/calendar_public_holiday_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023-2025 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import api, fields, models


class CalendarHolidaysPublicLine(models.Model):
_inherit = "calendar.public.holiday.line"

city_ids = fields.Many2many(
"res.city",
"hr_holiday_public_city_rel",
"line_id",
"city_id",
"Related Cities",
)

@api.constrains("city_ids")
def _check_date_state_city_ids(self):
self._check_date_state()

@api.constrains("city_ids")
def _update_calendar_event_city_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.city_ids:
domain += [("city_ids", "!=", False)]
return domain

def _get_domain_check_date_state_one(self):
domain = super()._get_domain_check_date_state_one()
domain += [("city_ids", "=", False)]
return domain

def _prepare_holidays_meeting_values(self):
res = super()._prepare_holidays_meeting_values()
if self.city_ids:
res["description"] += ": " + ", ".join(self.city_ids.mapped("name"))
return res
32 changes: 32 additions & 0 deletions hr_holidays_public_city/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
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 city domain
city_id = employee.address_id.city_id.id
if not city_id:
city_id = self.env.company.partner_id.city_id.id or False
if city_id:
domain.extend(
[
"|",
("city_ids", "=", city_id),
("city_ids", "=", False),
]
)
return domain
3 changes: 3 additions & 0 deletions hr_holidays_public_city/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions hr_holidays_public_city/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [Tecnativa](https://www.tecnativa.com)
- Pedro M. Baeza
- Víctor Martínez
- [APSL](https://apsl.tech):
- Antoni Marroig \<<amarroig@apsl.net>\>
- [Niboo](https://www.niboo.com):
- Simon Falesse
2 changes: 2 additions & 0 deletions hr_holidays_public_city/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds the cities at the public vacation line level as an
extra discriminant.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions hr_holidays_public_city/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading