-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
[17.0][ADD] project_timesheet_holidays_contract
#1290
base: 17.0
Are you sure you want to change the base?
[17.0][ADD] project_timesheet_holidays_contract
#1290
Conversation
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.
pre-approving, some minor suggestions
project_timesheet_holidays_contract/tests/test_hr_employee_calendar.py
Outdated
Show resolved
Hide resolved
project_timesheet_holidays_contract/tests/test_hr_leave_days_timesheet.py
Outdated
Show resolved
Hide resolved
e6804d5
to
fe6f507
Compare
fe6f507
to
4214bf0
Compare
4214bf0
to
4c78005
Compare
@SilvioC2C PR is updated, thanks for the perfect suggestions. |
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.
Could use some more tests, but overall LGTM
Thanks for your work!
f2bfc8d
to
81c88c6
Compare
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.
Code looks ok but after reviewing it I'm still not sure what this module brings.
Module allows to take into account employee contract along with provided | ||
end date when timesheet on time off. |
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.
IMO you could develop a bit more how this works, because after reading it twice, I'm still not sure what the module does.
# If only one contract, return it regardless of its state | ||
if len(contracts) == 1: | ||
return contracts[0].resource_calendar_id | ||
|
||
# Filter out cancelled contracts if there are multiple contracts | ||
valid_contracts = contracts.filtered(lambda c: c.state != "cancel") |
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.
So in case there's only one contract that is canceled, it still must be used? 🤨
self = self.with_context(date_to=to_datetime) | ||
|
||
result = {} | ||
for employee in self: |
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.
For all these functions, wouldn't grouping employees by calendar improve perf instead of iterating through all the employees?
@@ -0,0 +1 @@ | |||
Module allows to take into account employee contract along with provided end date when timesheet on time off. |
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.
Can you elaborate here a bit?
contracts = ( | ||
self.sudo() | ||
.with_context(active_test=True) | ||
.env["hr.contract"] | ||
.search( | ||
[ | ||
("employee_id", "=", self.id), | ||
("date_start", "<=", date_from), | ||
"|", | ||
("date_end", ">=", date_to), | ||
("date_end", "=", False), | ||
] | ||
) | ||
) | ||
|
||
# If only one contract, return it regardless of its state | ||
if len(contracts) == 1: | ||
return contracts[0].resource_calendar_id | ||
|
||
# Filter out cancelled contracts if there are multiple contracts | ||
valid_contracts = contracts.filtered(lambda c: c.state != "cancel") |
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.
I tested this w/ Odoo standard code, and I think states are not handled correctly.
Contracts can be differentiated in these macro-groups:
state == 'close'
: the contract is considered as expired for the employeestate == 'cancel'
: the contract is considered as cancelled for the employeestate == 'open' and kanban_state != 'blocked'
: the contract is considered as running for the employeestate == 'open' and kanban_state == 'blocked'
: the contract is considered as running for the employee, but will be closed as soon as the end date is reachedstate == 'draft' and kanban_state != 'done'
: the contract is not running for the employeestate == 'draft' and kanban_state == 'done'
: the contract is not running for the employee, but will be moved to "open" as soon as the contract's start date is met
This is something that should be taken into account when retrieving the employee's contract, and therefore its calendar.
Module allows to take into account employee contract along with provided end date when timesheet on time off.