Skip to content

Commit 0495318

Browse files
[FIX] hr_holidays: fix time off type error in time off form view
1. Go to **Time Off > Configuration > Time Off Types**. 2. Open a type and click the "Time Off" smart button. 3. Click **New**. 4. An error appears. [[Reference Video](https://drive.google.com/file/d/1vi_apL24Km5tSomQtwcTArqqWvrBR5ni/view)] In the `_search_virtual_remaining_leaves` method, the code tries to use an operator (like `>`) to compare the `virtual_remaining_leaves`. This operator requires **two** arguments to work. However, the code was only passing **one** argument, missing the `value` to compare against. This caused the "expects 2 arguments" error. Passed the missing `value` to the operator call so the comparison can be completed correctly. Task: 5241685
1 parent af46c2a commit 0495318

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

addons/hr_holidays/models/hr_leave_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def _search_virtual_remaining_leaves(self, operator, value):
280280
leave_types = self.env['hr.leave.type'].search([])
281281

282282
def is_valid(leave_type):
283-
return not leave_type.requires_allocation or op(leave_type.virtual_remaining_leaves)
283+
return not leave_type.requires_allocation or op(leave_type.virtual_remaining_leaves, value)
284284
return [('id', 'in', leave_types.filtered(is_valid).ids)]
285285

286286
@api.depends_context('employee_id', 'default_employee_id', 'leave_date_from', 'default_date_from')

addons/hr_holidays/tests/test_hr_leave_type.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ def test_users_tz_shift_back(self):
114114
).search([('has_valid_allocation', '=', True)], limit=1)
115115

116116
self.assertFalse(leave_types, "Got valid leaves outside vaild period")
117+
118+
def test_search_virtual_remaining_leaves(self):
119+
leave_types = self.env['hr.leave.type']._search_virtual_remaining_leaves('>', 0)
120+
self.assertEqual(len(leave_types), 1, f"Expected 1 leave type, found {leave_types}")

0 commit comments

Comments
 (0)