diff --git a/addons/hr_holidays/static/src/components/accrual_day_field/accrual_day_field.js b/addons/hr_holidays/static/src/components/accrual_day_field/accrual_day_field.js new file mode 100644 index 0000000000000..144792c0c4342 --- /dev/null +++ b/addons/hr_holidays/static/src/components/accrual_day_field/accrual_day_field.js @@ -0,0 +1,28 @@ +import { registry } from "@web/core/registry"; +import { SelectionField } from "@web/views/fields/selection/selection_field"; +import { standardFieldProps } from "@web/views/fields/standard_field_props"; + +export class AccrualDayField extends SelectionField { + + static props = { + ...standardFieldProps, + monthField: { + type: String, + } + } + + get options() { + let options = super.options; + const carryover_month = this.props.record.data[this.props.monthField]; + const lastDay = new Date(2020, carryover_month, 0).getDate(); + options = options.filter((option) => option[0] <= lastDay); + return options; + } +} + +registry.category("fields").add("accrual_day", { + component: AccrualDayField, + extractProps: ({ attrs }) => ({ + monthField: attrs.monthField + }) +}); diff --git a/addons/hr_holidays/views/hr_leave_accrual_views.xml b/addons/hr_holidays/views/hr_leave_accrual_views.xml index 53e2df20c6ff2..2634d52e9016f 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