Skip to content

[FIX] hr_holidays: fix search on virtual_remaining_leaves - #5214

Merged
HashemKhaled merged 1 commit into
master-hr-onboarding-tomicfrom
master-hr-onboarding-traceback_time_off_type-tomic
Aug 7, 2026
Merged

[FIX] hr_holidays: fix search on virtual_remaining_leaves#5214
HashemKhaled merged 1 commit into
master-hr-onboarding-tomicfrom
master-hr-onboarding-traceback_time_off_type-tomic

Conversation

@tonymchl

@tonymchl tonymchl commented Aug 5, 2026

Copy link
Copy Markdown

Steps to reproduce:

  • Configure a time off type with "Requires Allocation" set to True and "Allows Negative" set to False.
  • Create a valid allocation for an employee on this type.
  • Create a new time off request for the employee and click on the "Time Off Type" dropdown field.
  • A RPC_ERROR occurs (TypeError: gt expected 2 arguments, got 1).

Cause:
In hr_work_entry_type.py, the _search_virtual_remaining_leaves method's internal is_valid function evaluates op(work_entry_type.virtual_remaining_leaves) with only one argument instead of passing the comparison value as the second argument.

Solution:
Pass value as the second argument to op() in _search_virtual_remaining_leaves (i.e. op(work_entry_type.virtual_remaining_leaves, value)).

Task: 6446513

@robodoo

robodoo commented Aug 5, 2026

Copy link
Copy Markdown

This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-tomic, it needs to be retargeted before it can be merged.

@HashemKhaled HashemKhaled left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for your work 🚀

The bug is also reproducible if the time type does not require allocation, so let's make the commit message more generic to include all possible cases. I think it is enough to just try creating a time off and pressing the time type, the bug appears directly.

I am waiting for the test to be added as well.

@tonymchl
tonymchl force-pushed the master-hr-onboarding-traceback_time_off_type-tomic branch 2 times, most recently from 9d6f3f3 to 6eeeab5 Compare August 6, 2026 06:24
Steps to reproduce:
- Open the Time Off app.
- Create a new time off request.
- Click on the "Time Off Type" dropdown field.
- A traceback occurs (TypeError: gt expected 2 arguments, got 1).

Cause:
In `hr_work_entry_type.py`, the `_search_virtual_remaining_leaves` method's
internal `is_valid` function evaluates `op(work_entry_type.virtual_remaining_leaves)`
with only one argument instead of passing the comparison value as the second argument.

Solution:
Pass `value` as the second argument to `op()` in `_search_virtual_remaining_leaves`
(i.e. `op(work_entry_type.virtual_remaining_leaves, value)`).

Task: 6446513
@tonymchl
tonymchl force-pushed the master-hr-onboarding-traceback_time_off_type-tomic branch from 7878335 to 230ccd6 Compare August 6, 2026 14:51
'unit_of_measure': 'day',
})

domain = [('virtual_remaining_leaves', '>', 0)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: this is referenced only once so you can use it directly where it is needed

res = self.env['hr.work.entry.type'].with_user(self.user_employee_id).name_search(
            name='',
            domain=[('virtual_remaining_leaves', '>', 0)],
            operator='ilike',
            limit=8,
        )

@HashemKhaled HashemKhaled left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@HashemKhaled
HashemKhaled merged commit 5ae945b into master-hr-onboarding-tomic Aug 7, 2026
@HashemKhaled
HashemKhaled deleted the master-hr-onboarding-traceback_time_off_type-tomic branch August 7, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants