Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

UncaughtPromiseError > OwlError

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
#upgrade#OWL#odoo17#widget#odoo16
2 Respuestas
2913 Vistas
Avatar
Anthony Taylor

Getting an error while trying to update a custom module of mine.  I get this error when trying to edit any page which uses a dynamic widget I'm making.

UncaughtPromiseError > OwlError
Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)
....
Caused by: TypeError: Cannot read properties of undefined (reading 'forEach')

Here is the contents of the main.js from which I think the error stems from?  I'm unsure because there is no 'forEach' in my code.

/** @odoo-module **/

import publicWidget from "@web/legacy/js/public/public_widget";

publicWidget.registry.BannerManager = publicWidget.Widget.extend({
    selector: '.banner-manager',
    init: function () {
        this.rpc = this.bindService("rpc");
    },
    start: function () {
        let bannerRow = this.el.querySelector('#banner-manager-row');

        if (bannerRow){
                let html = ``;
                let count = 0;

                this._fetchData().then(banners => {
                    while(count                       html += `

                               
                       
`;
                      } else {
                        html += `">
                               
                        `;
                      }
                      count++;
                    }
                    bannerRow.innerHTML = html;
                  });
        }
    },
    async _fetchData() {
        const bannerData = await this.rpc('/get_banners',{});
        return(bannerData);
    },
});

export default publicWidget.registry.BannerManager;

Any help debugging would be appreciated.


0
Avatar
Descartar
Avatar
Anthony Taylor
Autor Mejor respuesta

I'm not sure exactly why, but after merging your code with mine it suddenly started working perfectly.

Thank you.

0
Avatar
Descartar
Avatar
OdooNomad
Mejor respuesta

The error Cannot read properties of undefined (reading 'forEach') suggests that somewhere in your code, you are trying to call forEach on an undefined value. However, you mentioned that there is no forEach in your code, which indicates the issue might be coming from the data structure or response you are handling.

Let's go through the code to identify potential issues and ensure everything is correctly handled.

  1. Initialization of this.rpc: Make sure this.rpc is properly initialized.
  2. Handling the response from _fetchData: Ensure the data returned by _fetchData is what you expect it to be.
  3. Error Handling: Add error handling to catch any issues when fetching or processing data.

Here is the revised version of your code with added error handling and some corrections:

 
/** @odoo-module **/

import publicWidget from "@web/legacy/js/public/public_widget";

publicWidget.registry.BannerManager = publicWidget.Widget.extend({
    selector: '.banner-manager',
    init: function () {
        this._super(...arguments);
        this.rpc = this.bindService("rpc");
    },
    start: async function () {
        let bannerRow = this.el.querySelector('#banner-manager-row');

        if (bannerRow) {
            let html = '';
            let count = 0;

            try {
                const banners = await this._fetchData();
                banners.forEach(banner => {
                    if (count % 2 === 0) {
                        html += `
                                    
                                 
`;
                    } else {
                        html += `
                                    
                                 
`;
                    }
                    count++;
                });
                bannerRow.innerHTML = html;
            } catch (error) {
                console.error('Error fetching banners:', error);
            }
        }
    },
    async _fetchData() {
        try {
            const bannerData = await this.rpc('/get_banners', {});
            if (!Array.isArray(bannerData)) {
                throw new Error('Invalid banner data format');
            }
            return bannerData;
        } catch (error) {
            console.error('Error in _fetchData:', error);
            throw error;
        }
    },
});

export default publicWidget.registry.BannerManager;


0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
can't open Accoutning App odoo 17 Enterprise
Accounting #odoo17
Avatar
Avatar
1
jul 24
1675
Help Needed: Implementing Home Delivery with Draft Billing in Odoo POS Resuelto
#pos #help #odoo16
Avatar
Avatar
1
ago 24
1462
Odoo Helpdesk Help Center | Odoo 17 Resuelto
Helpdesk #odoo17 Helpcenter
Avatar
1
jun 24
1871
Global Discount Odoo 17
#python #sale #discount #odoo17
Avatar
0
nov 24
123
Filter contacts for assigned pricelist
#pricelist #odoo17 #sales #saas
Avatar
0
jun 24
1481
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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