Skip to content

Conversation

@HashemKhaled
Copy link

@HashemKhaled HashemKhaled commented Nov 4, 2025

Steps to reproduce:
Navigate to Time Off >> Configuration >> Time Off Types >> Open any type, navigate to the Smart button Time Off >> Click on New >> Time Off Type
Leads to an error. [Reference Video]

Reason:
The op function is a comparison operator function that expects two values to compare and we are only passing to it leave_type.virtual_remaining_leaves parameter.

Solution:
Added the missing value parameter.

Task: 5238200

@robodoo
Copy link

robodoo commented Nov 4, 2025

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

@HashemKhaled HashemKhaled self-assigned this Nov 4, 2025
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.

Hello your commit message is not correct :D
image

@HashemKhaled HashemKhaled force-pushed the master-hr-onboarding-fix_leave_type_search-hkafe branch from 8370a8c to d8fbc33 Compare November 5, 2025 10:22
@HashemKhaled
Copy link
Author

Hello your commit message is not correct :D image

Hello, thanks for pointing me out to this! I thought we do not need to do it for small changes 🫣

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.

you also need to add a test :D as it's a bugfix task :)

@HashemKhaled HashemKhaled force-pushed the master-hr-onboarding-fix_leave_type_search-hkafe branch from d8fbc33 to 1df0172 Compare November 7, 2025 09:07
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.

LGTM

Comment on lines 138 to 188
test_cases = [
# (operator, value, expected_leave_type_1, expected_leave_type_2, description_type_1, description_type_2)
(
">",
0,
True,
True,
"should be in the result as it has remaining leaves",
"should be in the result since it does not require allocation",
),
(
"=",
0,
False,
True,
"should not be in the result as it has remaining leaves != 0",
"should be in the result since it does not require allocation",
),
(
">",
4,
False,
True,
"should not be in the result",
"should be in the result since it does not require allocation",
),
]

for (
operator,
value,
expected_type_1,
expected_type_2,
description_type_1,
description_type_2,
) in test_cases:
result = (
self.env["hr.leave.type"]
.with_context(employee_id=employee.id)
.search([("virtual_remaining_leaves", operator, value)])
)
self.assertIn(
leave_type_1, result, f"Leave Type 1 {description_type_1}",
) if expected_type_1 else self.assertNotIn(
leave_type_1, result, f"Leave Type 1 {description_type_1}",
)
self.assertIn(
leave_type_2, result, f"Leave Type 2 {description_type_2}",
) if expected_type_2 else self.assertNotIn(
leave_type_2, result, f"Leave Type 2 {description_type_2}",
)

Choose a reason for hiding this comment

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

Having a loop here seems like a good idea because it could be repetitive but for testing, it is actually best to repeat and be more verbose to have a more readable and maintainable test.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I thought parameterizing the tests would make more sense to avoid repetition, but I am also aligned with you that being more verbose in tests is better.

**Steps to reproduce:**
Navigate to Time Off >> Configuration >> Time Off Types >> Open any type, navigate to the Smart button Time Off >> Click on New >> Time Off Type
Leads to an error.

Reference Video: https://drive.google.com/file/d/1vi_apL24Km5tSomQtwcTArqqWvrBR5ni/view?usp=drive_link

**Reason:**
The `op` function is a comparison operator function that expects two values to compare and we are only passing to it `leave_type.virtual_remaining_leaves` parameter.

**Solution:**
Added the missing `value` parameter.

Task: 5238200
@HashemKhaled HashemKhaled force-pushed the master-hr-onboarding-fix_leave_type_search-hkafe branch from 1df0172 to 125e66c Compare November 7, 2025 16:13
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.

5 participants