Skip to content

Commit

Permalink
[FIX][hr_holidays_natural_period] date min/max start/end
Browse files Browse the repository at this point in the history
Signed-off-by: Luis Felipe Miléo <[email protected]>
  • Loading branch information
mileo committed Dec 4, 2024
1 parent d09c1a6 commit d094633
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hr_holidays_natural_period/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Copyright 2020-2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from datetime import datetime

from odoo import api, models


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

def _get_number_of_days(self, date_from, date_to, employee_id):
instance = self.with_context(
natural_period=bool(self.holiday_status_id.request_unit == "natural_day")
)

if self.holiday_status_id.request_unit:
instance = self.with_context(natural_period=True)
date_from = datetime.combine(date_from, datetime.min.time())
date_to = datetime.combine(date_to, datetime.max.time())

return super(HrLeave, instance)._get_number_of_days(
date_from, date_to, employee_id
)
Expand Down

0 comments on commit d094633

Please sign in to comment.