Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Comment thread
arpi-odoo marked this conversation as resolved.

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);
10 changes: 5 additions & 5 deletions addons/hr_holidays/views/hr_leave_accrual_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
</span>
<span name="biyearly" invisible="frequency != 'biyearly'">
on the
<field nolabel="1" name="first_month_day" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
<field nolabel="1" name="first_month_day" widget="day_selection" month="first_month" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
of
<field name="first_month" class="o_hr_narrow_field-5" placeholder="select a month" required="frequency == 'biyearly'"/>
and the
<field nolabel="1" name="second_month_day" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
<field nolabel="1" name="second_month_day" widget="day_selection" month="second_month" class="o_hr_narrow_field-3" placeholder="select a day" required="frequency == 'biyearly'"/>
of
<field nolabel="1" name="second_month" class="o_hr_narrow_field-5" placeholder="select a month" required="frequency == 'biyearly'"/>
</span>
<span name="yearly" invisible="frequency != 'yearly'">
on the
<field nolabel="1" name="yearly_day" class="o_hr_narrow_field-3" required="frequency == 'yearly'" placeholder="select a day"/>
<field nolabel="1" name="yearly_day" widget="day_selection" month="yearly_month" class="o_hr_narrow_field-3" required="frequency == 'yearly'" placeholder="select a day"/>
of
<field nolabel="1" name="yearly_month" class="o_hr_narrow_field-5" required="frequency == 'yearly'" placeholder="select a month"/>
</span>
Expand Down Expand Up @@ -204,8 +204,8 @@
options="{'links': {'other': 'carryover_custom_date'}, 'observe': 'carryover'}"/>
<span id="carryover_custom_date">
: the
<field name="carryover_day" placeholder="select a day"
required="carryover_date == 'other'"/>
<field name="carryover_day" placeholder="select a day" widget="day_selection" month="carryover_month"
required="carryover_date == 'other'" class="w-100"/>
of
<field name="carryover_month" placeholder="select a month"
required="carryover_date == 'other'"/>
Expand Down