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