Skip to content

Commit

Permalink
Fix: add overlapping days on right holiday type (#120)
Browse files Browse the repository at this point in the history
* Fix: add overlapping days on right holiday type

* Add translation for overlapping days
  • Loading branch information
albig authored Jan 30, 2025
1 parent d7011d4 commit 9ba232e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions hr_holidays_overlap/models/hr_leave_type.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Copyright 2023 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)


from odoo import fields, models


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

Expand All @@ -23,7 +21,8 @@ def _get_employees_days_per_allocation(self, employee_ids, date=None):
for this in result[employee_id]:
allocation_dict = result[employee_id][this]
for possible_overlap, _overlap, number_of_days in self._get_overlap(
employee_id
employee_id,
this.id
):
for allocation, allocation_days in allocation_dict.items():
if (
Expand All @@ -35,6 +34,7 @@ def _get_employees_days_per_allocation(self, employee_ids, date=None):
)
):
continue
# found allocation which is right now valid
allocation_days["virtual_remaining_leaves"] += number_of_days
allocation_days["virtual_leaves_taken"] -= number_of_days
if possible_overlap.state == "validate":
Expand All @@ -53,7 +53,7 @@ def _get_employees_days_per_allocation(self, employee_ids, date=None):
del allocation_dict[False]
return result

def _get_overlap(self, employee_id):
def _get_overlap(self, employee_id, leave_type):
"""Return overlapping leaves and the working time of the overlap"""
HrLeave = self.env["hr.leave"]

Expand All @@ -75,7 +75,7 @@ def _get_overlap(self, employee_id):
("id", "not in", possible_overlap.ids),
("date_from", "<=", possible_overlap.date_to),
("date_to", ">=", possible_overlap.date_from),
("holiday_status_id", "in", self.ids),
("holiday_status_id", "=", leave_type),
]
):
number_of_days = overlap.employee_id._get_work_days_data_batch(
Expand Down
6 changes: 3 additions & 3 deletions verdigado_attendance/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ msgstr ""
#: code:addons/verdigado_attendance/static/src/xml/hr_holidays.xml:0
#, python-format
msgid "(incl."
msgstr ""
msgstr "(inkl."

#. module: hr_attendance_break
#: model:mail.template,body_html:hr_attendance_break.template_mandatory_break
Expand Down Expand Up @@ -732,7 +732,7 @@ msgstr ""
#: code:addons/verdigado_attendance/static/src/xml/hr_holidays.xml:0
#, python-format
msgid "from"
msgstr ""
msgstr "aus"

#. module: hr_attendance_break
#. openerp-web
Expand All @@ -746,7 +746,7 @@ msgstr ""
#: code:addons/verdigado_attendance/static/src/xml/hr_holidays.xml:0
#, python-format
msgid "overlaps"
msgstr ""
msgstr "Überlappungen"

#. module: hr_attendance_break
#. openerp-web
Expand Down
3 changes: 2 additions & 1 deletion verdigado_attendance/models/hr_leave_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def _get_days_request(self):
overlap_ids = []
overlap_time = 0.0
for overlap1, overlap2, time in self._get_overlap(
self._get_contextual_employee_id()
self._get_contextual_employee_id(),
leave_type=self.id
):
overlap_ids += overlap1.ids + overlap2.ids
overlap_time += time
Expand Down

0 comments on commit 9ba232e

Please sign in to comment.