day_selection
In time off accrual plans, Odoo lets you say on the 30th of April but never on the 31st. That guard is day_selection, an hr_holidays widget that trims a day dropdown to the days its companion month actually has.
| Technical name | day_selection |
|---|---|
| Field types | selection |
| Views | form |
| Module | hr_holidays |
| Used in core | 4 occurrences across 1 module: hr_holidays (accrual plan carryover and milestone forms) |
| Versions | Odoo 20.0, Odoo 19.0 |
| No-code setup | No. Studio offers the plain Selection widget; the month filter needs the month_field attribute in XML. |
| Alternatives | selection, date, radio |
What the Day Selection widget does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
month_field (attribute) | field name | Required XML attribute naming the selection field on the same record that holds the month (numeric keys 1 to 12). The widget filters its day entries to that month's length and auto declares the field as a dependency so it is always loaded.(since Odoo 19.0) |
month_field is an attribute on the field tag, not an entry in options="{...}". Omitting it renders the widget with a missing prop: the day list falls back to unfiltered and Owl logs a props validation error in debug mode. Always pair the attribute.
Working examples
Why February keeps 29 days, and other filter mechanics
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Present in the development branch with mechanical framework changes only; see below. |
| Odoo 19.0 | Verified | Widget introduced; verified against the shipped source and tested on a clean database. |
| Odoo 18.0 | Not available | Does not exist; accrual day fields render as plain selection dropdowns. |
| Odoo 17.0 | Not available | Does not exist. |
| Odoo 16.0 | Not available | Does not exist. |
Migrating accrual customizations from 18 to 19: views that used a plain selection for these day fields can adopt the widget by adding widget="day_selection" and the month_field attribute; the fields themselves are unchanged.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| The dropdown shows no days at all | The month field's selection keys are not numeric, so the length computation produces NaN and every entry is filtered out. Store month values as numeric keys (1 to 12) in the month selection field. |
| Props validation error about monthField in debug mode | The month_field attribute is missing on the field tag; the component declares it as a required prop. Add month_field="your_month_field" to the XML. |
| February offers the 29th and you need it blocked | The filter is computed against 2020, a leap year, by design. Add a server side constraint or override the widget; the source always allows day 29 for February. |
| Day list does not shrink when the month changes | The widget reads the month from record data; if another widget on the month field does not commit its change, the day list cannot react. Keep the month field in the same view and let it save normally; the day options recompute on render. |
Day Selection widget vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
day_selection | Day of month dropdowns that must respect a month picked on the same record | Filters selection entries by the companion month's real length, leap year included |
| selection | Plain dropdowns with no cross field logic | Offers every entry regardless of other fields |
date | Picking a full calendar date | Real date field with a calendar popover instead of two selections |
| radio | Short choice lists shown all at once | Renders buttons side by side and cannot filter by another field |
Frequently asked questions
What does the day_selection widget do in Odoo?+
How do I link the day dropdown to my month field?+
Why does February show 29 days?+
Can I use day_selection outside HR?+
Is day_selection available in Odoo 18?+
Accrual plans that never miscount a day
Time off accruals, carryover rules and month day edge cases are where HR configurations quietly leak days. We implement and audit Odoo HR setups so balances match policy, February 29 included.
Review my time off setup