Skip to content

Conversation

@SurryaT10
Copy link

@SurryaT10 SurryaT10 commented Jan 7, 2026

Bug reproduction steps:

  1. Go to Time Off -> Configuration -> Accrual Plans.
  2. Create or edit a plan and add/edit a Milestone.
  3. Set the frequency to 'Yearly' or 'Twice a year'.
  4. Observe that the 'Day of month' selection allows choosing '31' even if the selected month is February or April.

Bug cause:
The 'day' and 'month' fields were treated as independent selection fields. The day field used a static selection list (1-31) defined in the Python model, which did not account for the varying lengths of months. This allowed for invalid dates like February 31st to be saved in the database.

Solution:
Created a new OWL field widget 'day_selector' that extends the standard SelectionField.

  • The widget accepts a 'month' attribute via the view to track the sibling month field.
  • It dynamically computes the 'options' list based on the selected month using a JavaScript Date logic.
  • It utilizes a 'useEffect' hook to monitor changes in the month field; if the month changes to one with fewer days than the currently selected day, the widget automatically updates the record to the maximum valid day for that month (e.g., shifting 31 to 30 or 28).
  • Updated the accrual plan form view to apply this widget to the milestone day fields.

task - 5468807

@robodoo
Copy link

robodoo commented Jan 7, 2026

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

@SurryaT10 SurryaT10 force-pushed the master-hr-onboarding-accrual_ux-sutha branch 12 times, most recently from 7cf37ea to c5e14d7 Compare January 12, 2026 09:40
Bug reproduction steps:
1. Go to Time Off -> Configuration -> Accrual Plans.
2. Create or edit a plan and add/edit a Milestone.
3. Set the frequency to 'Yearly' or 'Twice a year'.
4. Observe that the 'Day of month' selection allows choosing '31' even if the selected month is February or April.

Bug cause:
The 'day' and 'month' fields were treated as independent selection fields. The day field used a static selection list (1-31) defined in the Python model, which did not account for the varying lengths of months. This allowed for invalid dates like February 31st to be saved in the database.

Solution:
Created a new OWL field widget 'day_selector' that extends the standard SelectionField.
- The widget accepts a 'month' attribute via the view to track the sibling month field.
- It dynamically computes the 'options' list based on the selected month using a JavaScript Date logic.
- It utilizes a 'useEffect' hook to monitor changes in the month field; if the month changes to one with fewer days than the currently selected day, the widget automatically updates the record to the maximum valid day for that month (e.g., shifting 31 to 30 or 28).
- Updated the accrual plan form view to apply this widget to the milestone day fields.

task - 5468807
@SurryaT10 SurryaT10 force-pushed the master-hr-onboarding-accrual_ux-sutha branch from c5e14d7 to 99642e5 Compare January 12, 2026 09:41
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