Skip to content

Conversation

@ramezlahzy
Copy link

@ramezlahzy ramezlahzy commented Jan 5, 2026

Steps to reproduce:

  1. Go to Time Off > Configuration > Accrual Plans
  2. Create or edit an accrual plan
  3. Add a milestone with "Twice a year" or "Yearly" frequency
  4. Select February as the month
  5. Notice that day 31 can be selected, creating an invalid date

Bug cause:
The day fields used static Selection fields showing all days 1-31 regardless of the selected month, allowing invalid dates like "31st of February" to be configured.

Solution:

  • Added hr.leave.day.option model to store valid month/day combinations
  • Replaced first_month_day, second_month_day, and yearly_day Selection fields with Many2one fields that filter valid days per month
  • Implemented domain filters: [('month', '=', <month_field>)]
  • Added compute methods to auto-adjust day when month changes
  • Updated biyearly/yearly frequency calculations to use option values

Task Id:5457727

@robodoo
Copy link

robodoo commented Jan 5, 2026

This PR targets the un-managed branch odoo-dev/odoo:master-hr-onboarding-raibr, it needs to be retargeted before it can be merged.

@ramezlahzy ramezlahzy force-pushed the master-hr-time-off-ux-raibr branch 3 times, most recently from 0d6c0d2 to c573149 Compare January 8, 2026 12:47
Steps to reproduce:

Go to Time Off > Configuration > Accrual Plans
Create or edit an accrual plan
Add a milestone with “Twice a year” or “Yearly” frequency
Select February as the month
Notice that day 31 can be selected, creating an invalid date
Bug cause:

Day fields were plain Selection fields listing 1–31 regardless of the selected month, allowing invalid configurations like “31st of February”.

Solution:

Added a frontend field widget accrual_day that dynamically filters day options based on the selected month (leap-year aware) while reusing the core SelectMenu UI.
Updated first_month_day, second_month_day, and yearly_day in the accrual level form to use widget="accrual_day" so users only see valid days for the chosen month.
Kept existing Python compute methods (_compute_first_month_day, _compute_second_month_day, _compute_yearly_day) to auto-adjust values when months change, ensuring server-side correctness without schema changes.
Simplified the widget to rely on SelectionField’s template (no custom <select>) and keep the default styling; no new models or database changes.
Scope/Risk:

Low; changes are UI-only for accrual plan day selection and leverage existing backend compute safeguards.
Task-Id: 5457727
@ramezlahzy ramezlahzy force-pushed the master-hr-time-off-ux-raibr branch from c573149 to 223f1be Compare January 8, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants