-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
305e73d
feat: new validator list module
victorvermot 1937ed0
feat: overload more functions
victorvermot 7a177b5
fix: pre-commit corrections
victorvermot 194d39b
fix: modified code post reviews
victorvermot 055e9e2
fix: add modification in view tree
vrenaville e201d79
fix: change to correct model
vrenaville f73ef8b
Merge pull request #1 from vrenaville/vre_diff
vrenaville 440b0a6
fix: use sudo to remove the need to be employee/officer
vrenaville 6cf9406
feat: add context, to not trigger change of leave_manager_id based on…
vrenaville File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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. |
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 models | ||
from . import tests |
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,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, | ||
} |
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,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
60
hr_holidays_validator_list/i18n/hr_holidays_validator_list.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,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 "" |
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_employee | ||
from . import hr_leave |
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,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): | ||
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 |
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,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 |
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 @@ | ||
* Victor Vermot-Petit-Outhenin <[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 @@ | ||
This module allows for an employee to have several leave validators. |
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,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 |
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 test_hr_leave |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.