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_leave_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _search_virtual_remaining_leaves(self, operator, value):
leave_types = self.env['hr.leave.type'].search([])

def is_valid(leave_type):
return not leave_type.requires_allocation or op(leave_type.virtual_remaining_leaves)
return not leave_type.requires_allocation or op(leave_type.virtual_remaining_leaves, value)
return [('id', 'in', leave_types.filtered(is_valid).ids)]

@api.depends_context('employee_id', 'default_employee_id', 'leave_date_from', 'default_date_from')
Expand Down
4 changes: 4 additions & 0 deletions addons/hr_holidays/tests/test_hr_leave_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ def test_users_tz_shift_back(self):
).search([('has_valid_allocation', '=', True)], limit=1)

self.assertFalse(leave_types, "Got valid leaves outside vaild period")

def test_search_virtual_remaining_leaves(self):
leave_types = self.env['hr.leave.type']._search_virtual_remaining_leaves('>', 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should call the regular search method on the field virtual_remaining_leaves :)

self.assertEqual(len(leave_types), 1, f"Expected 1 leave type, found {leave_types}")