Skip to content

Commit

Permalink
Merge PR #117 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed May 24, 2024
2 parents cef403f + 9d0c0a2 commit b7987ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions hr_holidays_natural_period/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020-2022 Tecnativa - Víctor Martínez
# Copyright 2020-2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import api, models


class HrLeave(models.Model):
Expand All @@ -14,3 +14,13 @@ def _get_number_of_days(self, date_from, date_to, employee_id):
return super(HrLeave, instance)._get_number_of_days(
date_from, date_to, employee_id
)

@api.model_create_multi
def create(self, vals_list):
"""Only in UX an incorrect value is set, recalculate.
https://github.com/OCA/hr-holidays/issues/105."""
res = super().create(vals_list)
res.filtered(
lambda x: x.holiday_status_id.request_unit == "natural_day"
)._compute_number_of_days()
return res
4 changes: 2 additions & 2 deletions hr_holidays_natural_period/models/hr_leave_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def _get_employees_days_per_allocation(self, employee_ids, date=None):
"""We need to set request_unit as 'day' to avoid the calculations being done
as hours.
Related code:
hr_holidays/models/hr_leave_type.py#L313
hr_holidays/models/hr_leave_type.py#L367
hr_holidays/models/hr_leave_type.py#L326
hr_holidays/models/hr_leave_type.py#L389
"""
old_request_unit_data = {}
for item in self.filtered(lambda x: x.request_unit == "natural_day"):
Expand Down

0 comments on commit b7987ef

Please sign in to comment.