Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to fix TypeError: Cannot convert undefined or null to object

Odebírat

Get notified when there's activity on this post

This question has been flagged
javascript18.0
1 Odpovědět
6207 Zobrazení
Avatar
Omar El Zaatari

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!

0
Avatar
Zrušit
Avatar
Gracious Joseph
Nejlepší odpověď

The error TypeError: Cannot convert undefined or null to object typically occurs because an object or property you're trying to use in your code is either undefined or null. Based on the provided code and error message, here's a detailed analysis and fix for the issue:

Root Cause

The error arises when the patch function tries to apply a patch to dateField.prototype or DateTimeField.prototype, but one or both of these are undefined or improperly imported in your module.

The problem seems to stem from this line:

javascriptCopy codeimport { dateField, DateTimeField } from "@web/views/fields/datetime/datetime_field";
  • Odoo 18 (or 16) may not define dateField or DateTimeField as exported members in the module @web/views/fields/datetime/datetime_field. This means you're importing something that does not exist or has changed in the newer version.

Steps to Fix

1. Check the Imports

Ensure the imports match the actual exported objects in @web/views/fields/datetime/datetime_field. Check the source code of this module to confirm whether dateField and DateTimeField are available.

  • You can inspect Odoo’s source code for this module or log the imported objects:
    javascriptCopy codeimport * as datetimeField from "@web/views/fields/datetime/datetime_field";
    console.log(datetimeField);
    
  • If dateField or DateTimeField is undefined, it means these are not part of the module's exports.

2. Update the Module Path or Import Statement

In newer Odoo versions, there might be changes in the structure of the module. Check if dateField or DateTimeField is located in another module. For instance:

javascriptCopy codeimport { DateTimeField } from "@web/views/fields/fields";

If dateField does not exist, you can drop it from your imports.

3. Ensure Luxon Is Properly Imported

Ensure that the luxon library is available in your environment and properly imported:

javascriptCopy codeimport { DateTime } from "luxon";

Odoo typically includes Luxon in its dependencies, but verify this by logging DateTime:

javascriptCopy codeconsole.log(DateTime);

If DateTime is undefined, install Luxon in your development environment:

bashCopy codenpm install luxon

4. Update the patch Function Calls

The patch function attempts to extend the prototypes of dateField and DateTimeField. If either is undefined, it will throw an error.

To prevent this error, add defensive checks before applying patches:

javascriptCopy codeif (dateField) {
    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");
        },
    });
}

if (DateTimeField) {
    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");
        },
    });
}

This ensures the patch is only applied when the target object exists.


5. Debugging Missing Objects

If dateField or DateTimeField is completely missing from Odoo 18, it may have been deprecated or replaced. In this case:

  1. Search the Odoo source code for similar objects.
  2. Update your module to patch the replacement objects or write a custom implementation.

Conclusion

Here’s the key takeaway:

  • Ensure dateField and DateTimeField exist in your version of Odoo.
  • Use defensive programming (e.g., checks for undefined) when applying patches.
  • Verify dependencies like luxon are correctly installed and accessible.

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
[@$%$AviancaTeResponde$%$@]¿Cómo se llama Avianca en Colombia?
javascript
Avatar
0
lis 25
3
Cannot import @website_sale/js/utils
javascript
Avatar
Avatar
2
lis 25
501
How To Hide Action Report By Picking Type Code ?
18.0
Avatar
Avatar
Avatar
3
lis 25
514
How do I set up budget management / planning Vyřešeno
18.0
Avatar
Avatar
2
srp 25
1051
Cómo cerrar una transferencia interna al recibirla desde la vista de código de barras stock.picking
javascript
Avatar
0
čvc 25
1107
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now