You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
31 lines
1.2 KiB
/** @odoo-module */
|
|
import { TimeOffCalendarModel } from '@hr_holidays/views/calendar/calendar_model';
|
|
import { serializeDate } from "@web/core/l10n/dates";
|
|
import { patch } from "@web/core/utils/patch";
|
|
//The patch function to modify the TimeOffCalendarModel prototype by adding or
|
|
//modifying several methods and properties: setup, updateData,
|
|
//fetchPublicHolidays, and a getter for publicHolidays.
|
|
patch(TimeOffCalendarModel.prototype, 'hr_holidays.TimeOffCalendarModel',{
|
|
setup(params, services) {
|
|
this._super(params, services);
|
|
this.data.publicHolidays = {};
|
|
if (this.env.isSmall) {
|
|
this.meta.scale = 'month';
|
|
}
|
|
},
|
|
async updateData(data) {
|
|
await this._super(data);
|
|
data.publicHolidays = await this.fetchPublicHolidays(data);
|
|
},
|
|
// Fetches public holidays in a year
|
|
async fetchPublicHolidays(data) {
|
|
return this.orm.call("hr.employee", "get_public_holidays", [
|
|
this.employeeId,
|
|
serializeDate(data.range.start, "datetime"),
|
|
serializeDate(data.range.end, "datetime"),
|
|
]);
|
|
},
|
|
get publicHolidays() {
|
|
return this.data.publicHolidays;
|
|
}
|
|
});
|
|
|