odoo 16 enable fullcalender vertical resource view

239 Views Asked by At

I try to enable vertical resource view in Odoo 16 calendar.

I did:

npm install --save @fullcalendar/core  @fullcalendar/resource @fullcalendar/resource-timegrid`

and put an import statement in web/static/src/views/calendar/hooks.js like

async function loadJsFiles() {
const files = \[
"/web/static/lib/fullcalendar/core/main.js",
"/web/static/lib/fullcalendar/interaction/main.js",
"/web/static/lib/fullcalendar/daygrid/main.js",
"/web/static/lib/fullcalendar/luxon/main.js",
"/web/static/lib/fullcalendar/timegrid/main.js",
"/web/static/lib/fullcalendar/list/main.js",
"/web/static/lib/fullcalendar/node_modules/@fullcalendar/resource-daygrid/index.js",
\];

for (const file of files) {
await loadJS(file);
}
}

When I run this, I always get

SyntaxError: Cannot use import statement outside a module

I don't know what I'm doing wrong. Does anyone know what is wrong or can anyone explain how to implement fullcalender vertical resource view in Odoo 16? I know that I have to call the resource plugin with options in "web/static/src/views/calendar/calendar_common/calendar_common_renderer.js", but at the moment I can't even load the js file.

2

There are 2 best solutions below

0
klausjulius On

Blockquote

sorry, i just saw that odoo 16 comes with fullcalendar 4.4.0. i did npm install --save @fullcalendar/core @fullcalendar/resource @fullcalendar/resource-timegrid ` and fullcalendar premium 6.x.x was installed.

So it could not work. now i have another problem: the daily resources are displayed correctly but i can see now time values or a grid

0
klausjulius On

finally i got it working, except the default view. its always the week view that shows at first.

i initiate the views in /web/static/src/views/calendar/calendar_common/calendar_common_renderer.js

const SCALE_TO_FC_VIEW = {
    day: "resourceTimeGridDay",
    week: "timeGridWeek",
    month: "dayGridMonth",
};

and in get options:
........
defaultView: SCALE_TO_FC_VIEW[this.props.model.scale],

but i cant get the day view set to default. i tried initilView as well. does anyone know how to do it?