Skip to content

Commit

Permalink
[IMP] hr_attendance_validation: Ignoring some leave types
Browse files Browse the repository at this point in the history
we are using hr.leaves to manage allowed remote days but we
don't want to remove thoses times in attendance validation
  • Loading branch information
petrus-v committed Nov 15, 2023
1 parent 604c5b6 commit 8688b25
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 8 deletions.
5 changes: 4 additions & 1 deletion hr_attendance_validation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Hr Attendance Validation
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1996ce653eae83ec08b80a71833cd66791b5940ba7b519e5b523c94b05be5cc7
!! source digest: sha256:2e79147e731da1ca237d66ae8153a50ebcf15571fb74a0bf7b554bfec0d9949c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -66,6 +66,9 @@ Configuration
* Ensure employee weeks are properly set
* Set the leave type to use by generating compensatory
hours from attendance review (to be done in hr attendance configuration)
* You can ignore some leaves in validation sheet by ticking the "Ignored in attendance validation"
(for instance it can be useful if you manage employee remote days using hr.leave
in such case you want to ignore those lines)
* once all leaves and attendances has been recorded you can generate leave reviews
by setting up a cron job running every monday morning to generate the previous week
with the following code on `hr.attendance.validation.sheet` model::
Expand Down
1 change: 1 addition & 0 deletions hr_attendance_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"views/hr_attendance_validation.xml",
"views/hr_attendance.xml",
"views/res_config_settings_views.xml",
"views/hr_leave_type.xml",
"security/ir.model.access.csv",
"security/ir.rule.xml",
"data/ir_cron.xml",
Expand Down
16 changes: 13 additions & 3 deletions hr_attendance_validation/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ msgstr "Calendrier de l'employé."
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__display_name
msgid "Display Name"
Expand Down Expand Up @@ -280,11 +281,17 @@ msgstr "Heures effectuées cette semaine"
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__id
msgid "ID"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__ignored_in_attendance_validation
msgid "Ignored In Attendance Validation"
msgstr "Ignoré dans les feuilles de revue de présences"

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance__is_overtime_due
msgid "Is overtime due"
Expand All @@ -295,6 +302,7 @@ msgstr "Heure suplémentaire due"
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar____last_update
msgid "Last Modified on"
Expand Down Expand Up @@ -440,6 +448,11 @@ msgstr ""
msgid "Time Off"
msgstr "Congés"

#. module: hr_attendance_validation
#: model:ir.model,name:hr_attendance_validation.model_hr_leave_type
msgid "Time Off Type"
msgstr "Type de congés"

#. module: hr_attendance_validation
#: model:ir.model.fields.selection,name:hr_attendance_validation.selection__hr_attendance_validation_sheet__state__draft
#: model_terms:ir.ui.view,arch_db:hr_attendance_validation.hr_attendance_validation_sheet_view_form
Expand Down Expand Up @@ -528,6 +541,3 @@ msgid ""
msgstr ""
"Vous avez modifié un paramètre nécessitant de relancer la récupération des "
"lignes de présence et congés."

#~ msgid "Attendance validation sheets"
#~ msgstr "Revue des présences"
13 changes: 13 additions & 0 deletions hr_attendance_validation/i18n/hr_attendance_validation.pot
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ msgstr ""
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__display_name
msgid "Display Name"
Expand Down Expand Up @@ -259,11 +260,17 @@ msgstr ""
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__id
msgid "ID"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__ignored_in_attendance_validation
msgid "Ignored In Attendance Validation"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance__is_overtime_due
msgid "Is overtime due"
Expand All @@ -274,6 +281,7 @@ msgstr ""
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar____last_update
msgid "Last Modified on"
Expand Down Expand Up @@ -416,6 +424,11 @@ msgstr ""
msgid "Time Off"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model,name:hr_attendance_validation.model_hr_leave_type
msgid "Time Off Type"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields.selection,name:hr_attendance_validation.selection__hr_attendance_validation_sheet__state__draft
#: model_terms:ir.ui.view,arch_db:hr_attendance_validation.hr_attendance_validation_sheet_view_form
Expand Down
16 changes: 13 additions & 3 deletions hr_attendance_validation/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ msgstr "Definire la schedulazione della risorsa"
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__display_name
msgid "Display Name"
Expand Down Expand Up @@ -280,11 +281,17 @@ msgstr "Ore settimana corrente"
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings__id
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar__id
msgid "ID"
msgstr "ID"

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type__ignored_in_attendance_validation
msgid "Ignored In Attendance Validation"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance__is_overtime_due
msgid "Is overtime due"
Expand All @@ -295,6 +302,7 @@ msgstr "Straordinario dovuto"
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_attendance_validation_sheet____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_employee_base____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_hr_leave_type____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_res_config_settings____last_update
#: model:ir.model.fields,field_description:hr_attendance_validation.field_resource_calendar____last_update
msgid "Last Modified on"
Expand Down Expand Up @@ -439,6 +447,11 @@ msgstr ""
msgid "Time Off"
msgstr "Ferie"

#. module: hr_attendance_validation
#: model:ir.model,name:hr_attendance_validation.model_hr_leave_type
msgid "Time Off Type"
msgstr ""

#. module: hr_attendance_validation
#: model:ir.model.fields.selection,name:hr_attendance_validation.selection__hr_attendance_validation_sheet__state__draft
#: model_terms:ir.ui.view,arch_db:hr_attendance_validation.hr_attendance_validation_sheet_view_form
Expand Down Expand Up @@ -523,6 +536,3 @@ msgid ""
msgstr ""
"È cambiato il dipendente e/o data: bisogna recuperare le presenze e\n"
" permessi per queste nuove impostazioni."

#~ msgid "Attendance validation sheets"
#~ msgstr "Prospetti validazione presenza"
1 change: 1 addition & 0 deletions hr_attendance_validation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from . import hr_attendance
from . import hr_leave
from . import hr_leave_type
from . import hr_attendance_validation_sheet
from . import hr_employee
from . import resource_calendar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ def _retrieve_leave(self):
[
("state", "in", ["validate", "validate1"]),
("employee_id", "=", record.employee_id.id),
(
"holiday_status_id.ignored_in_attendance_validation",
"=",
False,
),
],
expression.OR(
[
Expand Down
9 changes: 9 additions & 0 deletions hr_attendance_validation/models/hr_leave_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2023 Pierre Verkest
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import fields, models


class HrLeaveType(models.Model):
_inherit = "hr.leave.type"

ignored_in_attendance_validation = fields.Boolean()
3 changes: 3 additions & 0 deletions hr_attendance_validation/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
* Ensure employee weeks are properly set
* Set the leave type to use by generating compensatory
hours from attendance review (to be done in hr attendance configuration)
* You can ignore some leaves in validation sheet by ticking the "Ignored in attendance validation"
(for instance it can be useful if you manage employee remote days using hr.leave
in such case you want to ignore those lines)
* once all leaves and attendances has been recorded you can generate leave reviews
by setting up a cron job running every monday morning to generate the previous week
with the following code on `hr.attendance.validation.sheet` model::
Expand Down
6 changes: 5 additions & 1 deletion hr_attendance_validation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Hr Attendance Validation</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1996ce653eae83ec08b80a71833cd66791b5940ba7b519e5b523c94b05be5cc7
!! source digest: sha256:2e79147e731da1ca237d66ae8153a50ebcf15571fb74a0bf7b554bfec0d9949c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-attendance/tree/14.0/hr_attendance_validation"><img alt="OCA/hr-attendance" src="https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-attendance-14-0/hr-attendance-14-0-hr_attendance_validation"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This add a validation mechanism to review employee attendance
Expand Down Expand Up @@ -415,6 +415,10 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<li><p class="first">Set the leave type to use by generating compensatory
hours from attendance review (to be done in hr attendance configuration)</p>
</li>
<li><p class="first">You can ignore some leaves in validation sheet by ticking the “Ignored in attendance validation”
(for instance it can be useful if you manage employee remote days using hr.leave
in such case you want to ignore those lines)</p>
</li>
<li><p class="first">once all leaves and attendances has been recorded you can generate leave reviews
by setting up a cron job running every monday morning to generate the previous week
with the following code on <cite>hr.attendance.validation.sheet</cite> model:</p>
Expand Down
36 changes: 36 additions & 0 deletions hr_attendance_validation/tests/test_hr_attendance_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ def setup_employee_holidays(self):
)
self.empl_leave_comp.action_validate()

def setup_employee_remote_days(self):
self.env["hr.leave.allocation"].create(
{
"employee_id": self.employee.id,
"holiday_status_id": self.leave_remote.id,
"number_of_days": 5,
"holiday_type": "employee",
"state": "validate",
"name": "5 days - Remote days",
}
)
self.empl_remote = self.env["hr.leave"].create(
{
"employee_id": self.employee.id,
"holiday_status_id": self.leave_remote.id,
# overlap two weeks
"request_date_from": "2021-12-09",
"request_date_to": "2021-12-10",
"number_of_days": 1,
}
)
self.empl_remote.action_validate()

def setup_employee_attendances(self):
self.env["hr.attendance"].create(
[
Expand Down Expand Up @@ -149,9 +172,22 @@ def setUp(self):
self.HrAttendanceValidation = self.env["hr.attendance.validation.sheet"]
self.leave_cl = self.env.ref("hr_holidays.holiday_status_cl")
self.leave_comp = self.env.ref("hr_holidays.holiday_status_comp")
self.leave_remote = self.env["hr.leave.type"].create(
{
"name": "Remote test",
"code": "REM1",
"request_unit": "half_day",
"color_name": "blue",
"allocation_type": "fixed",
"leave_validation_type": "no_validation",
"create_calendar_meeting": True,
"ignored_in_attendance_validation": True,
}
)
self.setup_employee()
self.setup_employee_allocation()
self.setup_employee_holidays()
self.setup_employee_remote_days()
self.setup_employee_attendances()

def test_name_get_missing_employee(self):
Expand Down
19 changes: 19 additions & 0 deletions hr_attendance_validation/views/hr_leave_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2023 CGI37 (http://www.cgi37.com/)
@author: Pierre Verkest <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>

<record id="edit_holiday_status_form" model="ir.ui.view">
<field name="name">hr.leave.type.form</field>
<field name="model">hr.leave.type</field>
<field name="inherit_id" ref="hr_holidays.edit_holiday_status_form" />
<field name="arch" type="xml">
<field name="code" position="after">
<field name="ignored_in_attendance_validation" />
</field>
</field>
</record>
</odoo>

0 comments on commit 8688b25

Please sign in to comment.