Hello, I'm trying to integrate an open source odoo 16 module that I found online in Odoo 18 but I'm receiving the following error in the developer console of chrome.
web.assets_web.min.js:17 Uncaught Error: Error while loading "@datetime_calendar/components/datetime_calendar":
TypeError: Cannot convert undefined or null to object
at ModuleLoader.startModule (web.assets_web.min.js:17:225)
at ModuleLoader.startModules (web.assets_web.min.js:16:57)
at ModuleLoader.addJob (web.assets_web.min.js:13:39)
at ModuleLoader.define (web.assets_web.min.js:12:127)
at web.assets_web.min.js:20259:6
And here's the code:
/* @odoo-module */
import { dateField, DateTimeField } from "@web/views/fields/datetime/datetime_field";import { patch } from "@web/core/utils/patch";const { DateTime } = luxon;const { useState } = owl;
console.log(DateTimeField);
function setCalendar(date, calendar, format = DateTime.DATE_FULL) { console.log("setCalendar called with:", date, calendar); if (!date) return ''; const luxonDate = DateTime.fromISO(date); if (!luxonDate.isValid) return ''; return luxonDate.reconfigure({ outputCalendar: calendar }).toLocaleString(format);}
patch(dateField.prototype, { setup() { this._super?.(); console.log("setup: Value of this.props.value:", this.props.value);
this.calendar = useState({ 'hebrew': setCalendar(this.props.value || DateTime.now().toISO(), "hebrew"), 'islamic': setCalendar(this.props.value || DateTime.now().toISO(), "islamic"), }); },
onDateTimeChanged(date) { this._super?.(date); this.calendar.islamic = setCalendar(date, "islamic"); },
get formattedValue() { return this.isDateTime ? setCalendar(this.props.value, "islamic", DateTime.DATETIME_MED) : setCalendar(this.props.value, "islamic"); },});
patch(DateTimeField.prototype, { setup() { this._super?.(); console.log("setup: Value of this.props.value:", this.props.value);
this.calendar = useState({ 'hebrew': setCalendar(this.props.value || DateTime.now().toISO(), "hebrew"), 'islamic': setCalendar(this.props.value || DateTime.now().toISO(), "islamic"), }); },
onDateTimeChanged(date) { this._super?.(date); this.calendar.islamic = setCalendar(date, "islamic"); },
get formattedValue() { return setCalendar(this.props.value, "islamic"); },});
Why is this error showing, and how can I fix it?
Thank you!