From 26306650c644b5121e1aecbae5d53fcf3fc9bb34 Mon Sep 17 00:00:00 2001 From: arpi-odoo Date: Mon, 1 Dec 2025 15:28:29 +0100 Subject: [PATCH 1/2] [IMP] empty From 3108e1fb7fa2a59341e624b114644fb01fea709e Mon Sep 17 00:00:00 2001 From: abshe Date: Fri, 12 Dec 2025 11:57:18 +0100 Subject: [PATCH 2/2] [IMP] hr_holidays: making day selection field depending on the month Before, you could select day 31 for 30/29/28 days month in accural plan levels added custom widget for day selection to adapt with the selected month Task #5404372 --- .../month_specific_days.js | 29 +++++++++++++++++++ .../views/hr_leave_accrual_views.xml | 8 ++--- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 addons/hr_holidays/static/src/components/month_specific_days/month_specific_days.js diff --git a/addons/hr_holidays/static/src/components/month_specific_days/month_specific_days.js b/addons/hr_holidays/static/src/components/month_specific_days/month_specific_days.js new file mode 100644 index 0000000000000..15f0ff62bb3d3 --- /dev/null +++ b/addons/hr_holidays/static/src/components/month_specific_days/month_specific_days.js @@ -0,0 +1,29 @@ +import { registry } from "@web/core/registry"; +import { SelectionField, selectionField } from "@web/views/fields/selection/selection_field"; + +export class MonthSpecificDays extends SelectionField { + static props = { + ...SelectionField.props, + monthFieldName: String, + }; + + get options() { + const days = this.props.record.fields[this.props.name].selection; + const month = this.props.record.data[this.props.monthFieldName]; + const lastDay = new Date(2024, month, 0).getDate(); // method call will return last day of the month, used 2024 as it's a leap year + return days.filter((day) => day[0] <= lastDay); + } +} + +export const monthSpecificDays = { + ...selectionField, + component: MonthSpecificDays, + extractProps({ options }) { + return { + ...selectionField.extractProps(...arguments), + monthFieldName: options.depends_on, + }; + }, +}; + +registry.category("fields").add("month_specific_days", monthSpecificDays); diff --git a/addons/hr_holidays/views/hr_leave_accrual_views.xml b/addons/hr_holidays/views/hr_leave_accrual_views.xml index 53e2df20c6ff2..45b074ca63d9a 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 @@ -192,7 +192,7 @@ options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/> : the - of