Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/hr_holidays/models/hr_work_entry_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _search_max_leaves(self, operator, value):

def _search_virtual_remaining_leaves(self, operator, value):
def is_valid(work_entry_type):
return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves)
return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves, value)
op = PY_OPERATORS.get(operator)
if not op:
return NotImplemented
Expand Down
1 change: 1 addition & 0 deletions addons/hr_holidays/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
from . import test_timeoff_overview_my_department_tour
from . import test_hr_leave_report
from . import test_member_of_department
from . import test_time_off_type
35 changes: 35 additions & 0 deletions addons/hr_holidays/tests/test_time_off_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from odoo.tests import Form, tagged

from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon

class TestTimeOffType(TestHrHolidaysCommon):

@classmethod
def setUpClass(cls):

super().setUpClass()

cls.work_entry_type_paid = cls.env['hr.work.entry.type'].create({
'name': 'Paid Time Off',
'code': 'Paid Time Off',
'requires_allocation': True,
'request_unit': 'day',
'unit_of_measure': 'day',
'allows_negative' : False,
})

cls.allocation = cls.env['hr.leave.allocation'].create({
'name': 'Regular allocation',
'date_from': '2024-01-04',
'work_entry_type_id': cls.work_entry_type_paid.id,
'employee_id': cls.employee_emp.id,
'number_of_days': 10,
})
cls.allocation.action_approve()

def test_time_off_type_selection_with_existing_allocations(self):
self.env['hr.work.entry.type'].with_context(
default_employee_id=self.employee_emp.id,
).search([
('virtual_remaining_leaves', '>', 0),
])