diff --git a/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss b/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss index f6a930fd221024..93843403dfabfa 100644 --- a/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss +++ b/addons/hr_holidays/static/src/components/accrual_level/accrual_levels.scss @@ -10,7 +10,7 @@ } .o_accrual { - .o_field_accrual, .o_field_selection, .o_field_filterable_selection { + .o_field_accrual, .o_field_selection, .o_field_day_selection, .o_field_filterable_selection { width: fit-content !important; &:not(.o_readonly_modifier) > *:first-child { diff --git a/addons/hr_holidays/static/src/components/day_selection/day_selection.js b/addons/hr_holidays/static/src/components/day_selection/day_selection.js new file mode 100644 index 00000000000000..2f459c64e2d145 --- /dev/null +++ b/addons/hr_holidays/static/src/components/day_selection/day_selection.js @@ -0,0 +1,34 @@ +import { registry } from "@web/core/registry"; +import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field"; + +export class DaySelection extends SelectionField { + static props = { + ...SelectionField.props, + month: { type: String, optional: true }, + }; + + get options() { + const options = super.options; + const selectedMonth = this.props.record.data[this.props.month]; + if (!selectedMonth) return options; + + const maxDays = new Date(2024, parseInt(selectedMonth), 0).getDate(); + return options.filter(option => parseInt(option[0]) <= maxDays); + } +} + +export const daySelection = { + ...selectionField, + component: DaySelection, + extractProps({ attrs }) { + const props = selectionField.extractProps(...arguments); + props.month = attrs.month; + return props; + }, + fieldDependencies: ({ attrs }) => [ + { name: attrs.month, type: "selection" }, + ], +}; + + +registry.category("fields").add("day_selection", daySelection); diff --git a/addons/hr_holidays/views/hr_leave_accrual_views.xml b/addons/hr_holidays/views/hr_leave_accrual_views.xml index 0630b086ad787e..12fe7b3836927c 100644 --- a/addons/hr_holidays/views/hr_leave_accrual_views.xml +++ b/addons/hr_holidays/views/hr_leave_accrual_views.xml @@ -36,17 +36,17 @@ on the - + of and the - + of on the - + of @@ -204,8 +204,8 @@ options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/> : the - + of