-
-
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.
This module allows to template the name of the calendar meeting name created from validated hr leaves
- Loading branch information
Showing
17 changed files
with
920 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,77 @@ | ||
====================== | ||
Holidays calendar name | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:7369318bedbd8d7d442cb86ddfdb5afd3404993e989e8329c9aa317910708f58 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/14.0/hr_holidays_calendar_name | ||
: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-14-0/hr-holidays-14-0-hr_holidays_calendar_name | ||
: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=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
HR Officer can configure calendar template name on leave types to | ||
control labels on generated calendar event label from leaves. | ||
|
||
**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_calendar_name%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Pierre Verkest <[email protected]> | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Pierre Verkest <[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/14.0/hr_holidays_calendar_name>`_ 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,17 @@ | ||
# Copyright (C) 2018 Brainbean Apps (https://brainbeanapps.com) | ||
# Copyright 2020 CorporateHub (https://corporatehub.eu) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Holidays calendar name", | ||
"version": "14.0.1.0.0", | ||
"category": "Human Resources", | ||
"website": "https://github.com/OCA/hr-holidays", | ||
"author": "Pierre Verkest <[email protected]>, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"application": False, | ||
"summary": "Control leave employee calendar meeting name", | ||
"depends": ["hr_holidays"], | ||
"data": ["views/hr_leave_type.xml"], | ||
} |
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,101 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_holidays_calendar_name | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: code:addons/hr_holidays_calendar_name/models/hr_leave.py:0 | ||
#, python-format | ||
msgid "%.2f day(s)" | ||
msgstr "%.2f jour(s)" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: code:addons/hr_holidays_calendar_name/models/hr_leave.py:0 | ||
#, python-format | ||
msgid "%.2f hour(s)" | ||
msgstr "%.2f heure(s)" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__calendar_meeting_leave_template | ||
msgid "Calendar Meeting Leave Template" | ||
msgstr "Modèle de nom d'évènement du calendrier" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave__display_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__display_name | ||
msgid "Display Name" | ||
msgstr "Libellé" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave__id | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave____last_update | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,help:hr_holidays_calendar_name.field_hr_leave_type__calendar_meeting_leave_template | ||
msgid "" | ||
"Template used to generate calendar meeting name, \n" | ||
"ie: '%(employee_name)s on Time Off : %(formatted_duration)s' which is " | ||
"roughly the default behavior from odoo if you leave this field empty.Here " | ||
"the list of possible parameters: \n" | ||
"* `employee_or_category`: employee name or category if leave has no users " | ||
"linked\n" | ||
"* `employee_name`: employee name\n" | ||
"* `category_name`: hr category name (tag)\n" | ||
"* `formatted_duration`: number of ours or days with the unit according the " | ||
"kind of leave\n" | ||
"* `number_of_hours_display`: number of hours\n" | ||
"* `number_of_days`: number of days\n" | ||
"* `start`: start date\n" | ||
"* `stop`: end date\n" | ||
"* `leave_type_name`: leave type name\n" | ||
"* `leave_type_code`: leave type code\n" | ||
"* `leave_name`: leave name\n" | ||
msgstr "" | ||
"Modèle de nom utilisé pour générer le nom de calendrier (format %-string de " | ||
"python), \n" | ||
"ie: '%(employee_name)s en congés : %(formatted_duration)s' qui revient au " | ||
"comportement par défaut d'odoo (comme quand ce champ est vide). \n" | ||
"Voici la liste des paramètres disponibles : \n" | ||
"* `employee_or_category`: Nom de l'employée ou de la catégorie (tag) si la " | ||
"demande \n" | ||
"de congés n'a pas d'utilisateur lié.\n" | ||
"* `employee_name`: nom de l'employé\n" | ||
"* `category_name`: nom de la catégorie (tag)\n" | ||
"* `formatted_duration`: nombre d'heures ou de jours de congés formatté en " | ||
"fonction de l'utité confifuré sur le type\n" | ||
"* `number_of_hours_display`: nombre d'heures de congés\n" | ||
"* `number_of_days`: number de jours de congés\n" | ||
"* `start`: date de début\n" | ||
"* `stop`: date de fin\n" | ||
"* `leave_type_name`: nom du type de congés\n" | ||
"* `leave_type_code`: code du type de congés\n" | ||
"* `leave_name`: nom de la demande de congés\n" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model,name:hr_holidays_calendar_name.model_hr_leave | ||
msgid "Time Off" | ||
msgstr "Congés" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model,name:hr_holidays_calendar_name.model_hr_leave_type | ||
msgid "Time Off Type" | ||
msgstr "Type de congés" |
77 changes: 77 additions & 0 deletions
77
hr_holidays_calendar_name/i18n/hr_holidays_calendar_name.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,77 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * hr_holidays_calendar_name | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.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_calendar_name | ||
#: code:addons/hr_holidays_calendar_name/models/hr_leave.py:0 | ||
#, python-format | ||
msgid "%.2f day(s)" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: code:addons/hr_holidays_calendar_name/models/hr_leave.py:0 | ||
#, python-format | ||
msgid "%.2f hour(s)" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__calendar_meeting_leave_template | ||
msgid "Calendar Meeting Leave Template" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave__display_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave__id | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave____last_update | ||
#: model:ir.model.fields,field_description:hr_holidays_calendar_name.field_hr_leave_type____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model.fields,help:hr_holidays_calendar_name.field_hr_leave_type__calendar_meeting_leave_template | ||
msgid "" | ||
"Template used to generate calendar meeting name, \n" | ||
"ie: '%(employee_name)s on Time Off : %(formatted_duration)s' which is roughly the default behavior from odoo if you leave this field empty.Here the list of possible parameters: \n" | ||
"* `employee_or_category`: employee name or category if leave has no users linked\n" | ||
"* `employee_name`: employee name\n" | ||
"* `category_name`: hr category name (tag)\n" | ||
"* `formatted_duration`: number of ours or days with the unit according the kind of leave\n" | ||
"* `number_of_hours_display`: number of hours\n" | ||
"* `number_of_days`: number of days\n" | ||
"* `start`: start date\n" | ||
"* `stop`: end date\n" | ||
"* `leave_type_name`: leave type name\n" | ||
"* `leave_type_code`: leave type code\n" | ||
"* `leave_name`: leave name\n" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model,name:hr_holidays_calendar_name.model_hr_leave | ||
msgid "Time Off" | ||
msgstr "" | ||
|
||
#. module: hr_holidays_calendar_name | ||
#: model:ir.model,name:hr_holidays_calendar_name.model_hr_leave_type | ||
msgid "Time Off Type" | ||
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_leave | ||
from . import hr_leave_type |
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,47 @@ | ||
# Copyright 2023 CGI (https://www.cgi37.com/) | ||
# @author Pierre Verkest <[email protected]> | ||
# 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 _prepare_calendar_meeting_leave_name(self, default=""): | ||
self.ensure_one() | ||
if self.holiday_status_id.calendar_meeting_leave_template: | ||
if self.leave_type_request_unit == "hour": | ||
formatted_duration = _("%.2f hour(s)") % (self.number_of_hours_display,) | ||
else: | ||
formatted_duration = _("%.2f day(s)") % (self.number_of_days,) | ||
|
||
return self.holiday_status_id.with_context( | ||
lang=self.user_id.lang | ||
).calendar_meeting_leave_template % { | ||
"employee_or_category": self.employee_id.name or self.category_id.name, | ||
"employee_name": self.employee_id.name, | ||
"category_name": self.category_id.name, | ||
"formatted_duration": formatted_duration, | ||
"number_of_hours_display": self.number_of_hours_display, | ||
"number_of_days": self.number_of_days, | ||
"start": self.date_from, | ||
"stop": self.date_to, | ||
"leave_type_name": self.holiday_status_id.name, | ||
"leave_type_code": self.holiday_status_id.code, | ||
"leave_name": self.name, | ||
} | ||
return default | ||
|
||
def _prepare_holidays_meeting_values(self): | ||
result = super()._prepare_holidays_meeting_values() | ||
# this is a bit annoyed to loop over results | ||
# and browse leave from it but feel safer and | ||
# cleaner than overwrite the whole method | ||
for _user_id, meetings in result.items(): | ||
for meeting_values in meetings: | ||
leave = self.env["hr.leave"].browse(meeting_values["res_id"]).exists() | ||
if leave: | ||
meeting_values["name"] = leave._prepare_calendar_meeting_leave_name( | ||
default=meeting_values["name"] | ||
) | ||
return result |
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 (C) 2018 Brainbean Apps (https://brainbeanapps.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class HrLeaveType(models.Model): | ||
_inherit = "hr.leave.type" | ||
|
||
calendar_meeting_leave_template = fields.Char( | ||
translate=True, | ||
help=( | ||
"Template used to generate calendar meeting name, \n" | ||
"ie: '%(employee_name)s on Time Off : %(formatted_duration)s' which is roughly " | ||
"the default behavior from odoo if you leave this field empty." | ||
"Here the list of possible parameters: \n" | ||
"* `employee_or_category`: employee name or category if leave has no users " | ||
"linked\n" | ||
"* `employee_name`: employee name\n" | ||
"* `category_name`: hr category name (tag)\n" | ||
"* `formatted_duration`: number of ours or days with the unit according the " | ||
"kind of leave\n" | ||
"* `number_of_hours_display`: number of hours\n" | ||
"* `number_of_days`: number of days\n" | ||
"* `start`: start date\n" | ||
"* `stop`: end date\n" | ||
"* `leave_type_name`: leave type name\n" | ||
"* `leave_type_code`: leave type code\n" | ||
"* `leave_name`: leave name\n" | ||
), | ||
) |
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 @@ | ||
* Pierre Verkest <[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,2 @@ | ||
HR Officer can configure calendar template name on leave types to | ||
control labels on generated calendar event label from leaves. |
Oops, something went wrong.