Skip to content

Commit

Permalink
feat: overload more functions
Browse files Browse the repository at this point in the history
  • Loading branch information
victorvermot committed Nov 7, 2023
1 parent 305e73d commit 1937ed0
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 273 deletions.
Empty file.
1 change: 1 addition & 0 deletions hr_holidays_validator_list/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import tests
4 changes: 3 additions & 1 deletion hr_holidays_validator_list/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"license": "AGPL-3",
"depends": ["hr_holidays"],
"data": [
"views/hr_views.xml"
"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 ""
1 change: 1 addition & 0 deletions hr_holidays_validator_list/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import hr_employee
from . import hr_leave_allocation
21 changes: 19 additions & 2 deletions hr_holidays_validator_list/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,35 @@ class HrEmployeeBase(models.AbstractModel):

leave_manager_ids = fields.Many2many(
'res.users',
string='Time Off',
compute='_compute_leave_manager',
string='Time Off Managers',
store=True,
readonly=False,
help='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).',
)

def _set_leave_manager_id_from_leave_manager_ids(self, values):
if 'leave_manager_ids' in values:
if not len(values['leave_manager_ids'][0][-1]):
values['leave_manager_id'] = None
elif ('leave_manager_ids' in values.keys()):
values['leave_manager_id'] = values['leave_manager_ids'][0][-1][-1]

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):
self._set_leave_manager_id_from_leave_manager_ids(values)
res = super().create(values)
self._add_leave_manager_ids_in_group(values)
return res

def write(self, values):
self._set_leave_manager_id_from_leave_manager_ids(values)
res = super().write(values)
self._add_leave_manager_ids_in_group(values)
return res
22 changes: 19 additions & 3 deletions hr_holidays_validator_list/models/hr_leave_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@ class HolidaysAllocation(models.Model):
""" Allocation Requests Access specifications: similar to leave requests """
_inherit = "hr.leave.allocation"

def _get_responsible_for_approval(self):
print("Need to override it")
def activity_update(self):
"""updates activity for all leave_manager_ids"""
res = super().activity_update()
for manager in self.employee_id.leave_manager_ids:
old_manager = self.employee_id.leave_manager_id
self.employee_id.leave_manager_id = manager
super().activity_update()
self.employee_id.leave_manager_id = old_manager
return res

def _check_approval_update(self, state):
print("Need to override it")
"""checks that the leave manager is in leave_manager_ids"""
res = super()._check_approval_update(state)
for manager in self.employee_id.leave_manager_ids:
if manager == self.env.user:
old_manager = self.employee_id.leave_manager_id
self.employee_id.leave_manager_id = manager
super()._check_approval_update(state)
self.employee_id.leave_manager_id = old_manager
break
return res
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

0 comments on commit 1937ed0

Please sign in to comment.