Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
15
web_calendar_slot_duration/static/src/js/calendar_common_renderer.esm.js
Executable file
15
web_calendar_slot_duration/static/src/js/calendar_common_renderer.esm.js
Executable file
@@ -0,0 +1,15 @@
|
||||
/* Copyright 2023 Tecnativa - Stefan Ungureanu
|
||||
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
|
||||
|
||||
import {CalendarCommonRenderer} from "@web/views/calendar/calendar_common/calendar_common_renderer";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(CalendarCommonRenderer.prototype, {
|
||||
get options() {
|
||||
const options = super.options;
|
||||
if (this.env.searchModel.context.calendar_slot_duration) {
|
||||
options.slotDuration = this.env.searchModel.context.calendar_slot_duration;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
});
|
||||
24
web_calendar_slot_duration/static/src/js/calendar_model.esm.js
Executable file
24
web_calendar_slot_duration/static/src/js/calendar_model.esm.js
Executable file
@@ -0,0 +1,24 @@
|
||||
/* Copyright 2023 Tecnativa - Stefan Ungureanu
|
||||
|
||||
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
|
||||
|
||||
import {CalendarModel} from "@web/views/calendar/calendar_model";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(CalendarModel.prototype, {
|
||||
buildRawRecord(partialRecord, options = {}) {
|
||||
if (
|
||||
!partialRecord.end &&
|
||||
this.env.searchModel.context.calendar_slot_duration &&
|
||||
!partialRecord.isAllDay
|
||||
) {
|
||||
const slot_duration = this.env.searchModel.context.calendar_slot_duration;
|
||||
const [hours, minutes, seconds] = slot_duration
|
||||
.match(/(\d+):(\d+):(\d+)/)
|
||||
.slice(1, 4);
|
||||
const durationFloat = hours + minutes / 60 + seconds / 3600;
|
||||
partialRecord.end = partialRecord.start.plus({hours: durationFloat});
|
||||
}
|
||||
return super.buildRawRecord(partialRecord, options);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user