Skip to content

Commit

Permalink
Merge PR #96 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 10, 2023
2 parents d20a531 + 06c432f commit b99d2b3
Show file tree
Hide file tree
Showing 19 changed files with 892 additions and 0 deletions.
87 changes: 87 additions & 0 deletions hr_holidays_public_city/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
=======================
HR Holidays Public City
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0aa31e51e632f74b982fe2ccea262e12b0b08bcf49921ec28753f9fdada35573
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_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-16-0/hr-holidays-16-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=16.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:%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
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_

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

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/16.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": "16.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/hr_holidays_public_view.xml",
],
"installable": True,
"maintainers": ["victoralmau"],
}
38 changes: 38 additions & 0 deletions hr_holidays_public_city/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_public_city
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-12 06:53+0000\n"
"PO-Revision-Date: 2023-07-12 08:54+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.0.1\n"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public
msgid "Public Holidays"
msgstr "Festivos"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public_line
msgid "Public Holidays Lines"
msgstr "Líneas de Festivos"

#. module: hr_holidays_public_city
#: model:ir.model.fields,field_description:hr_holidays_public_city.field_hr_holidays_public_line__city_ids
msgid "Related Cities"
msgstr "Ciudades relacionadas"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_leave
msgid "Time Off"
msgstr "Tiempo libre"
34 changes: 34 additions & 0 deletions hr_holidays_public_city/i18n/hr_holidays_public_city.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_public_city
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public
msgid "Public Holidays"
msgstr ""

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public_line
msgid "Public Holidays Lines"
msgstr ""

#. module: hr_holidays_public_city
#: model:ir.model.fields,field_description:hr_holidays_public_city.field_hr_holidays_public_line__city_ids
msgid "Related Cities"
msgstr ""

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_leave
msgid "Time Off"
msgstr ""
37 changes: 37 additions & 0 deletions hr_holidays_public_city/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_public_city
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-08-01 12:12+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public
msgid "Public Holidays"
msgstr "Giorni festivi"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_holidays_public_line
msgid "Public Holidays Lines"
msgstr "Righe giorni festivi"

#. module: hr_holidays_public_city
#: model:ir.model.fields,field_description:hr_holidays_public_city.field_hr_holidays_public_line__city_ids
msgid "Related Cities"
msgstr "Città collegate"

#. module: hr_holidays_public_city
#: model:ir.model,name:hr_holidays_public_city.model_hr_leave
msgid "Time Off"
msgstr "Ferie"
2 changes: 2 additions & 0 deletions hr_holidays_public_city/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_holidays_public
from . import hr_leave
64 changes: 64 additions & 0 deletions hr_holidays_public_city/models/hr_holidays_public.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
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):
domain = super()._get_domain_states_filter(
pholidays=pholidays,
start_dt=start_dt,
end_dt=end_dt,
employee_id=employee_id,
)
employee = False
if employee_id:
employee = self.env["hr.employee"].browse(employee_id)
if employee and employee.address_id and employee.address_id.city_id:
domain += [
"|",
("city_ids", "=", False),
("city_ids", "=", employee.address_id.city_id.id),
]
else:
domain.append(("city_ids", "=", False))
return domain


class HrHolidaysPublicLine(models.Model):
_inherit = "hr.holidays.public.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
25 changes: 25 additions & 0 deletions hr_holidays_public_city/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
)
# Add city domain
city_id = self.env.user.employee_id.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
4 changes: 4 additions & 0 deletions hr_holidays_public_city/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_

* Pedro M. Baeza
* Víctor Martínez
1 change: 1 addition & 0 deletions hr_holidays_public_city/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
Loading

0 comments on commit b99d2b3

Please sign in to comment.