-
Notifications
You must be signed in to change notification settings - Fork 23.2k
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
[FW][FIX] hr_holidays: correctly calculate leave duration #166139
Closed
fw-bot
wants to merge
1
commit into
odoo:saas-16.4
from
odoo-dev:saas-16.4-16.0-opw-3703793-company_time_off_duration-taqu-1R2N-fw
Closed
[FW][FIX] hr_holidays: correctly calculate leave duration #166139
fw-bot
wants to merge
1
commit into
odoo:saas-16.4
from
odoo-dev:saas-16.4-16.0-opw-3703793-company_time_off_duration-taqu-1R2N-fw
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Steps ----- - Time off installed - Put an employee on a different schedule than the company's default one and make him for example start earlier. - Create a new Time Off type, set "Requires allocation" to No Limit. - Approvals > Time off > New and create a time off (mode "by company") on the day where the employee is starting earlier. - Approve it. - Approvals > Time off : the leave's duration for the employee on a different schedule is incorrect (slightly less than 1 day). Issue ----- When creating a leave on a company level, a leave will first be created with start and end hours based on the company's default schedule. When approving the leave, a leave is then created for each affected employee. The date_from and date_to received by create are based on the company's default schedule. This is not generally problematic as it is taken into account. For example, the date_from and date_to of the employee's leave are correct even if he is on a different schedule. However, when we compute the number of days, it is not accounted for. https://github.com/odoo/odoo/blob/64cbe389e698398eee93ebde9c61b2ee79756380/addons/hr_holidays/models/hr_leave.py#L918 https://github.com/odoo/odoo/blob/64cbe389e698398eee93ebde9c61b2ee79756380/addons/hr_holidays/models/hr_leave.py#L744 As a result, the hours worked by an employee on a different schedule which are "outside" of the company's default schedule don't count towards the calculation. https://github.com/odoo/odoo/blob/3eec4d6a69ff76cbf750b960dc8db2eb5e0a45f9/addons/resource/models/resource_mixin.py#L94-101 Note: the issue is the same for leaves given to a department or an employee tag since they are created the same way. Fix ----- Use the whole day as a basis for leave duration calculation if there is more than one schedule for the employees. Also add more logic to handle half days and hours leaves which had incorrect start and end hours. opw-3703793 X-original-commit: aaf27b4
@taqu-odoo @Bertrand2 this PR targets saas-16.4 and is the last of the forward-port chain. To merge the full chain, use
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
@fw-bot r+ |
robodoo
pushed a commit
that referenced
this pull request
May 21, 2024
Steps ----- - Time off installed - Put an employee on a different schedule than the company's default one and make him for example start earlier. - Create a new Time Off type, set "Requires allocation" to No Limit. - Approvals > Time off > New and create a time off (mode "by company") on the day where the employee is starting earlier. - Approve it. - Approvals > Time off : the leave's duration for the employee on a different schedule is incorrect (slightly less than 1 day). Issue ----- When creating a leave on a company level, a leave will first be created with start and end hours based on the company's default schedule. When approving the leave, a leave is then created for each affected employee. The date_from and date_to received by create are based on the company's default schedule. This is not generally problematic as it is taken into account. For example, the date_from and date_to of the employee's leave are correct even if he is on a different schedule. However, when we compute the number of days, it is not accounted for. https://github.com/odoo/odoo/blob/64cbe389e698398eee93ebde9c61b2ee79756380/addons/hr_holidays/models/hr_leave.py#L918 https://github.com/odoo/odoo/blob/64cbe389e698398eee93ebde9c61b2ee79756380/addons/hr_holidays/models/hr_leave.py#L744 As a result, the hours worked by an employee on a different schedule which are "outside" of the company's default schedule don't count towards the calculation. https://github.com/odoo/odoo/blob/3eec4d6a69ff76cbf750b960dc8db2eb5e0a45f9/addons/resource/models/resource_mixin.py#L94-101 Note: the issue is the same for leaves given to a department or an employee tag since they are created the same way. Fix ----- Use the whole day as a basis for leave duration calculation if there is more than one schedule for the employees. Also add more logic to handle half days and hours leaves which had incorrect start and end hours. opw-3703793 closes #166139 X-original-commit: aaf27b4 Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Steps
default one and make him for example start earlier.
No Limit.
company") on the day where the employee is starting earlier.
on a different schedule is incorrect (slightly less than 1 day).
Issue
When creating a leave on a company level, a leave will first be
created with start and end hours based on the company's default
schedule.
When approving the leave, a leave is then created for each
affected employee. The date_from and date_to received by
create are based on the company's default schedule. This is not
generally problematic as it is taken into account. For example,
the date_from and date_to of the employee's leave are correct
even if he is on a different schedule.
However, when we compute the number of days, it is not accounted for.
odoo/addons/hr_holidays/models/hr_leave.py
Line 918 in 64cbe38
odoo/addons/hr_holidays/models/hr_leave.py
Line 744 in 64cbe38
As a result, the hours worked by an employee on a different schedule
which are "outside" of the company's default schedule don't count
towards the calculation.
https://github.com/odoo/odoo/blob/3eec4d6a69ff76cbf750b960dc8db2eb5e0a45f9/addons/resource/models/resource_mixin.py#L94-101
Note: the issue is the same for leaves given to a department or an
employee tag since they are created the same way.
Fix
When creating a leave for employees, if the leave is not for half
days or hours, give the whole day as a leave to account for different
schedules. Note that the actual date_from and date_to of each employee's
leave are still based on their actual attendance, but if an employee
has hours outside of the company's schedule, they will count towards
the leave's duration.
opw-3703793
Forward-Port-Of: #165947
Forward-Port-Of: #161856