[FIX] hr_holidays: fix error when selecting time off type#5150
Conversation
|
This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-sevan, it needs to be retargeted before it can be merged. |
lebm-odoo
left a comment
There was a problem hiding this comment.
Helloooo, little comment, and you should write a test for this search method as it is a fix 👀
| def _search_virtual_remaining_leaves(self, operator, value): | ||
| def is_valid(work_entry_type): | ||
| return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves) | ||
| return not work_entry_type.requires_allocation or op(work_entry_type.virtual_remaining_leaves, work_entry_type.requires_allocation) |
There was a problem hiding this comment.
The purpose of a search method is to implement the search behavior on a field (that is not stored in db but computed for instance) and so here it's on virtual_remaining_leaves. So you have to implement each comparisons: (computed_value, operator, comparison_value)
so if someone search for work entry types with virtual remaining leaves under 15. It will compute for each work entry the virtual_remaining_leave and compare it with the < operator with 15.
So with your fix, the traceback is fixed but the search will not work.
There was a problem hiding this comment.
Oops, I misunderstood the method 😅
cf3d314 to
f62e68c
Compare
|
And don't forget to read the main message above the review 👀 a test still missing to be sure the _search method will never fail again 😄 |
8e4f918 to
f760374
Compare
|
I added a test method, let me know if it is sufficient for this fix 🤓 |
lebm-odoo
left a comment
There was a problem hiding this comment.
Helloooo, I think the test can be a bit better 😄
f760374 to
befc5f3
Compare
There was a TypeError after allocating a time off for an employee, validating it, creating the time off for this employee, and clicking on the Time Type selection. The bug was due to the private _search method. Added a test to ensure the search on work entry types works. Task: 6191029
befc5f3 to
5ece274
Compare
There was a TypeError after allocating a time off for an employee, validating it, creating the time off for this employee, and clicking on the Time Type selection.
Task: 6191029