Skip to content

Conversation

@Mohamed-Khaled308
Copy link

@Mohamed-Khaled308 Mohamed-Khaled308 commented Nov 6, 2025

Steps to Reproduce

  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]

Reason

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.

Solution

Passed the missing value to the operator call so the comparison can be completed correctly.

Task: 5241685

@robodoo
Copy link

robodoo commented Nov 6, 2025

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

@Mohamed-Khaled308 Mohamed-Khaled308 force-pushed the master-hr-onboarding-time_off_type_bug-moaln branch from eb044b7 to ae49b9c Compare November 6, 2025 09:01
Copy link

@mepe-odoo mepe-odoo left a comment

Choose a reason for hiding this comment

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

thanks for your work :D
As It's a bug fix task you need to add a test (this test need to fail before your fix and pass after)
Also in your commit message you need to add the step to reproduce the issue :D
But the fix seems good 👀

Image

@Mohamed-Khaled308 Mohamed-Khaled308 force-pushed the master-hr-onboarding-time_off_type_bug-moaln branch from ae49b9c to c44c21b Compare November 7, 2025 08:12
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
@Mohamed-Khaled308 Mohamed-Khaled308 force-pushed the master-hr-onboarding-time_off_type_bug-moaln branch from c44c21b to 0495318 Compare November 7, 2025 09:31
@Mohamed-Khaled308
Copy link
Author

Thank you very much for your review!
I added the unit test and changed the commit message.

Copy link

@mepe-odoo mepe-odoo left a comment

Choose a reason for hiding this comment

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

thanks for your work :D

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 :)

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.

4 participants