Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD][14.0] New module hr_holidays_validator_list #91

Closed
Closed
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
90 changes: 90 additions & 0 deletions hr_holidays_validator_list/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
==========================
HR Holidays validator list
==========================

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

.. |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_validator_list
: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_validator_list
: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|

This module allows for an employee to have several leave validators.

**Table of contents**

.. contents::
:local:

Usage
=====

For adding multiple :

#. Go to the menu *Employee > Field leave_manager_ids*.
#. Add managers in the new many2many field.
#. The validation type of the hr.leave should be "manager".

Other changes:

#. The "People I manage" filter in hr.leave and hr.leave.allocation have been
updated accordingly

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_validator_list%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
~~~~~~~

* Victor Vermot

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

* Victor Vermot-Petit-Outhenin <[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_validator_list>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions hr_holidays_validator_list/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import tests
19 changes: 19 additions & 0 deletions hr_holidays_validator_list/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "HR Holidays validator list",
"summary": "Allow to add several leave validators",
"author": "Victor Vermot, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-holidays",
"category": "Human Resources",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"depends": ["hr_holidays"],
"data": [
"views/hr_views.xml",
"views/hr_leave_allocation_views.xml",
"views/hr_leave_views.xml",
],
"installable": True,
}
62 changes: 62 additions & 0 deletions hr_holidays_validator_list/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_validator_list
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-07 10:12+0000\n"
"PO-Revision-Date: 2023-11-07 10:12+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_validator_list
#: model:ir.model,name:hr_holidays_validator_list.model_hr_employee_base
msgid "Basic Employee"
msgstr "Employé basique"

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation__id
msgid "ID"
msgstr "ID"

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: hr_holidays_validator_list
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee__leave_manager_ids
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee_base__leave_manager_ids
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee_public__leave_manager_ids
msgid ""
"Select the users responsible for approving \"Time Off\" of this employee.\n"
"If empty, the approval is done by an Administrator or Approver (determined in settings/users)."
msgstr ""
"Sélectionne le user responsable for approuvé les congés de l'employé.\n"
"Si vide, la validation est faite par un adiministrateur ou approuveur (comme configuré dans paramètres/utilisateurs)"

#. module: hr_holidays_validator_list
#: model:ir.model,name:hr_holidays_validator_list.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr "Allocation de congés"

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee__leave_manager_ids
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__leave_manager_ids
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_public__leave_manager_ids
msgid "Time Off Managers"
msgstr "Managers de congés"
60 changes: 60 additions & 0 deletions hr_holidays_validator_list/i18n/hr_holidays_validator_list.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_validator_list
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-07 10:12+0000\n"
"PO-Revision-Date: 2023-11-07 10:12+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_validator_list
#: model:ir.model,name:hr_holidays_validator_list.model_hr_employee_base
msgid "Basic Employee"
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation__display_name
msgid "Display Name"
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation__id
msgid "ID"
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_leave_allocation____last_update
msgid "Last Modified on"
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee__leave_manager_ids
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee_base__leave_manager_ids
#: model:ir.model.fields,help:hr_holidays_validator_list.field_hr_employee_public__leave_manager_ids
msgid ""
"Select the users responsible for approving \"Time Off\" of this employee.\n"
"If empty, the approval is done by an Administrator or Approver (determined in settings/users)."
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model,name:hr_holidays_validator_list.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr ""

#. module: hr_holidays_validator_list
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee__leave_manager_ids
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_base__leave_manager_ids
#: model:ir.model.fields,field_description:hr_holidays_validator_list.field_hr_employee_public__leave_manager_ids
msgid "Time Off Managers"
msgstr ""
2 changes: 2 additions & 0 deletions hr_holidays_validator_list/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_employee
from . import hr_leave
46 changes: 46 additions & 0 deletions hr_holidays_validator_list/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class HrEmployeeBase(models.AbstractModel):
_inherit = "hr.employee.base"

leave_manager_ids = fields.Many2many(
"res.users",
string="Time Off Managers",
store=True,
readonly=False,
help="""Select the users responsible for approving 'Time Off' of this employee.
If empty, the approval is done by an Administrator
or Approver (determined in settings/users).""",
)

@api.depends("parent_id", "leave_manager_ids")
def _compute_leave_manager(self):

for employee in self:
if employee.leave_manager_ids:
employee.leave_manager_id = employee.leave_manager_ids[0]
else:
super()._compute_leave_manager()

def _add_leave_manager_ids_in_group(self, values):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An onchange would have suffice to affect groups on managers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, we are on hr_employee, an onchange should only affect the values of the current form. Groups won't be available from here.

if "leave_manager_ids" in values:
approver_group = self.env.ref(
"hr_holidays.group_hr_holidays_responsible", raise_if_not_found=False
)
for manager_id in values["leave_manager_ids"][0][-1]:
if approver_group:
approver_group.sudo().write({"users": [(4, manager_id)]})

def create(self, values):
res = super().create(values)
self._add_leave_manager_ids_in_group(values)
return res

def write(self, values):
res = super().write(values)
self._add_leave_manager_ids_in_group(values)
return res
35 changes: 35 additions & 0 deletions hr_holidays_validator_list/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import models


class HolidaysLeave(models.Model):
"""Allocation Requests Access specifications: similar to leave requests"""

_inherit = "hr.leave"

def activity_update(self):
"""Updates activity for all leave_manager_ids"""
if not self.employee_id.leave_manager_ids or self.env.context.get(
"no_leave_manager_ids_trigger"
):
super().activity_update()
else:
for manager in self.employee_id.leave_manager_ids:
self.employee_id.sudo().leave_manager_id = manager
super().activity_update()
self.employee_id.sudo().leave_manager_id = False

def _check_approval_update(self, state):
"""Checks that the leave manager is in leave_manager_ids"""
if not self.employee_id.leave_manager_ids or self.env.context.get(
"no_leave_manager_ids_trigger"
):
super()._check_approval_update(state)
else:
for manager in self.employee_id.leave_manager_ids:
if manager == self.env.user:
self.employee_id.sudo().leave_manager_id = manager.id
super()._check_approval_update(state)
self.employee_id.sudo().leave_manager_id = False
1 change: 1 addition & 0 deletions hr_holidays_validator_list/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Victor Vermot-Petit-Outhenin <[email protected]>
1 change: 1 addition & 0 deletions hr_holidays_validator_list/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows for an employee to have several leave validators.
10 changes: 10 additions & 0 deletions hr_holidays_validator_list/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
For adding multiple :

#. Go to the menu *Employee > Field leave_manager_ids*.
#. Add managers in the new many2many field.
#. The validation type of the hr.leave should be "manager".

Other changes:

#. The "People I manage" filter in hr.leave and hr.leave.allocation have been
updated accordingly
1 change: 1 addition & 0 deletions hr_holidays_validator_list/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_hr_leave
Loading
Loading