-
Notifications
You must be signed in to change notification settings - Fork 116
[FIX] hr_holidays: fix search on leave type #4865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master-hr-onboarding-hkafe
Are you sure you want to change the base?
[FIX] hr_holidays: fix search on leave type #4865
Conversation
|
This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-hkafe, it needs to be retargeted before it can be merged. |
mepe-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8370a8c to
d8fbc33
Compare
mepe-odoo
left a comment
There was a problem hiding this 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 :)
d8fbc33 to
1df0172
Compare
mepe-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| 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}", | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
1df0172 to
125e66c
Compare


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
opfunction is a comparison operator function that expects two values to compare and we are only passing to itleave_type.virtual_remaining_leavesparameter.Solution:
Added the missing
valueparameter.Task: 5238200