From 9f523a6c0c2bceea15e276a3911b840e3d29362d Mon Sep 17 00:00:00 2001 From: SebVde Date: Mon, 11 May 2026 11:51:10 +0200 Subject: [PATCH] [IMP] hr_holidays: limit accrual plans and levels day selection based on selected month The day selection for accrual plans carryover date and accrual levels yearly date is now limited to 29 or 30 depending on which month is selected. Task: 6191776 --- .../components/day_selection/day_selection.js | 36 +++++++++++++++++++ .../views/hr_leave_accrual_views.xml | 8 ++--- 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 addons/hr_holidays/static/src/components/day_selection/day_selection.js 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..7683655b2c67ac --- /dev/null +++ b/addons/hr_holidays/static/src/components/day_selection/day_selection.js @@ -0,0 +1,36 @@ +import { selectionField, SelectionField } from "@web/views/fields/selection/selection_field"; +import { registry } from "@web/core/registry"; + +export class DaySelectionField extends SelectionField { + static props = { + ...SelectionField.props, + month: String, + }; + + get options() { + let allOptions = super.options; + const monthValue = this.props.record.data[this.props.month]; + const maxDay = new Date(2020, monthValue, 0).getDate(); + allOptions = allOptions.filter((option) => option[0] <= maxDay); + return allOptions; + } +} + +export const daySelectionField = { + ...selectionField, + component: DaySelectionField, + extractProps({ attrs }) { + return { + ...selectionField.extractProps(...arguments), + month: attrs.month, + }; + }, + fieldDependencies: ({ attrs }) => [ + { + name: attrs.month, + type: "selection", + }, + ], +}; + +registry.category("fields").add("day_selection", daySelectionField); diff --git a/addons/hr_holidays/views/hr_leave_accrual_views.xml b/addons/hr_holidays/views/hr_leave_accrual_views.xml index a097fdbec8f74b..08072d7788c6b3 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 @@ -195,7 +195,7 @@ options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/> : the - of