[FIX] hr_holidays: correct weekday display in accrual plan levels#265168
Closed
fw-bot wants to merge 1 commit into
Closed
Conversation
Steps to reproduce: 1. Install Time Off 2. Go to Accrual Plans and create a new plan with a milestone 3. Set frequency to Weekly and choose a day other than Monday (e.g., Tuesday) 4. Save and check the displayed weekday in the accrual plan level Issue: The displayed weekday is incorrect (e.g., shows Monday instead of Tuesday). Cause: Previously, the weekday value was directly displayed using: https://github.com/odoo/odoo/blob/b40184ab371f7a4708621ecf7f25b4e2daaae38d/addons/hr_holidays/views/hr_leave_accrual_views.xml#L212-L214 so no conversion was involved. Now, the value is processed using Luxon. However, the week_day field stores values from 0 (Monday) to 6 (Sunday), while the previous code used `luxon.DateTime.fromFormat(day, "c")`, which expects a 1-indexed value (1=Monday). This mismatch causes an off-by-one error during conversion. https://github.com/odoo/odoo/blob/1b3d0a3c2f794324f8b230a9ae19f097454e3bdd/addons/hr_holidays/models/hr_leave_accrual_plan_level.py#L54-L62 Solution: Use luxon.Info.weekdays() to retrieve weekday names directly from a 0-indexed array matching the stored week_day values. opw-6112614 X-original-commit: 6d3473b
Contributor
Contributor
Author
|
This PR targets saas-19.2 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
robodoo
pushed a commit
that referenced
this pull request
May 20, 2026
Steps to reproduce: 1. Install Time Off 2. Go to Accrual Plans and create a new plan with a milestone 3. Set frequency to Weekly and choose a day other than Monday (e.g., Tuesday) 4. Save and check the displayed weekday in the accrual plan level Issue: The displayed weekday is incorrect (e.g., shows Monday instead of Tuesday). Cause: Previously, the weekday value was directly displayed using: https://github.com/odoo/odoo/blob/b40184ab371f7a4708621ecf7f25b4e2daaae38d/addons/hr_holidays/views/hr_leave_accrual_views.xml#L212-L214 so no conversion was involved. Now, the value is processed using Luxon. However, the week_day field stores values from 0 (Monday) to 6 (Sunday), while the previous code used `luxon.DateTime.fromFormat(day, "c")`, which expects a 1-indexed value (1=Monday). This mismatch causes an off-by-one error during conversion. https://github.com/odoo/odoo/blob/1b3d0a3c2f794324f8b230a9ae19f097454e3bdd/addons/hr_holidays/models/hr_leave_accrual_plan_level.py#L54-L62 Solution: Use luxon.Info.weekdays() to retrieve weekday names directly from a 0-indexed array matching the stored week_day values. opw-6112614 closes #265168 X-original-commit: 6d3473b Signed-off-by: Mathias Lebel (lebm) <lebm@odoo.com> Signed-off-by: Bommisetty Narendra (bona) <bona@odoo.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 to reproduce:
Issue:
The displayed weekday is incorrect (e.g., shows Monday instead of Tuesday).
Cause:
Previously, the weekday value was directly displayed using:
odoo/addons/hr_holidays/views/hr_leave_accrual_views.xml
Lines 212 to 214 in b40184a
Now, the value is processed using Luxon. However, the week_day field stores values from 0 (Monday) to 6 (Sunday), while Luxon expects ISO weekday numbers from 1 (Monday) to 7 (Sunday). This mismatch causes an off-by-one error during conversion.
odoo/addons/hr_holidays/models/hr_leave_accrual_plan_level.py
Lines 54 to 62 in 1b3d0a3
Solution:
Adjust the value before passing it to Luxon by adding +1 to match ISO format.
opw-6112614
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: #259054