Skip to content

[FIX] hr_holidays: correct weekday display in accrual plan levels#265168

Closed
fw-bot wants to merge 1 commit into
odoo:saas-19.2from
odoo-dev:saas-19.2-saas-18.4-opw-6112614-correct-weekday-milestones-hr-holidays-bona-527721-fw
Closed

[FIX] hr_holidays: correct weekday display in accrual plan levels#265168
fw-bot wants to merge 1 commit into
odoo:saas-19.2from
odoo-dev:saas-19.2-saas-18.4-opw-6112614-correct-weekday-milestones-hr-holidays-bona-527721-fw

Conversation

@fw-bot
Copy link
Copy Markdown
Contributor

@fw-bot fw-bot commented May 19, 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:

<t t-if="record.frequency.raw_value === 'weekly'">
on <field name="week_day"/>
</t>
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 Luxon expects ISO weekday numbers from 1 (Monday) to 7 (Sunday). This mismatch causes an off-by-one error during conversion.

week_day = fields.Selection([
('0', 'Monday'),
('1', 'Tuesday'),
('2', 'Wednesday'),
('3', 'Thursday'),
('4', 'Friday'),
('5', 'Saturday'),
('6', 'Sunday'),
], default='0', required=True, string="Allocation on")

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

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
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented May 19, 2026

Pull request status dashboard

@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented May 19, 2026

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 robodoo added the forwardport This PR was created by @fw-bot label May 19, 2026
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>
@robodoo robodoo closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwardport This PR was created by @fw-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants