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
    • eLearning
    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
    • Información
    • 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 taberna
    • 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
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • 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
    Browse all Industries
  • 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
    • Services for 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

t-foreach not working on POS template screen

Suscribirse

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

Se marcó esta pregunta
javascriptposxmltemplateowl
2 Respuestas
4176 Vistas
Avatar
Panos Anagnostakis

I have created a button in POS product screen, to display a new screen. 

The js file for the button is : 

odoo.define('cdc_pos.ProductTotalSalesButton', function (require) {
    'use strict';
    const PosComponent=require('point_of_sale.PosComponent');
    const ProductScreen=require('point_of_sale.ProductScreen');
    const { useListener } =require("@web/core/utils/hooks");
    const Registries=require('point_of_sale.Registries');
    class ProductTotalSalesButton extends PosComponent {
    ​ ​setup() {
          ​ ​super.setup();
          ​​useListener('click', this.onClick);
        ​}
​​async onClick() {
                this.showScreen('ProductTotalSalesScreen')
        ​}                  
    }
    ProductTotalSalesButton.template='ProductTotalSalesButton';
   ProductScreen.addControlButton({
       component:ProductTotalSalesButton,
       condition:function() {
           returntrue;       },
    });
   Registries.Component.add(ProductTotalSalesButton);
   return ProductTotalSalesButton;
});

The button is added correctly and it is used to show a new screen called ProductTotalSalesScreen using the showScreen function.

The js and xml files for the new screen are:

odoo.define('cdc_pos.ProductTotalSalesScreen', function(require) {
    'use strict';
    const PosComponent=require('point_of_sale.PosComponent');
   const Registries=require('point_of_sale.Registries');
   class ProductTotalSalesScreen extends PosComponent {
        setup(){
            super.setup();
       }
        back() {
            this.showScreen('ProductScreen');
        }
    };
    ProductTotalSalesScreen.template='ProductTotalSalesScreen';
    Registries.Component.add(ProductTotalSalesScreen);
    return ProductTotalSalesScreen;
});

xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="ProductTotalSalesScreen" owl="1">
        <div class="top-content">
            <div class="button back" t-on-click="back">
                Back
            div>
        div>
        <t t-foreach="[1, 2, 3]" t-as="i">
            <p><t t-out="i"/>p>
        t>
    t>
templates> ​
When I click the show ProductTotalSalesScreen, there is an error in the browser console which just says "undefined"

If I comment out the t-foreach loop then the screen is displayed.

Is there any reason why the t-foreach loop part causes the undefined error?
I can't make t-foreach work for this new screen template...
0
Avatar
Descartar
Avatar
Juan Jose Carballo Samayoa
Mejor respuesta

<tt-set="cp"t-value="env.pos.componente_activo"/>

<tt-foreach="cp"t-as="componente"t-key="componente.id"> 

<td style="width: 30%"class="text-center">

<tt-esc="componente.name"/>

td>  

 

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

In this provided code there is an syntax mistake , update your code like this

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
    <t t-name="ProductTotalSalesScreen" owl="1">
        <div class="top-content">
            <div class="button back" t-on-click="back">
                Back
            </div>
        </div>
        <t t-foreach="[1, 2, 3]" t-as="i">
            <p><t t-out="i"/></p>
        </t>
    </t>
</templates>


Regards

0
Avatar
Descartar
Panos Anagnostakis
Autor

Hi! Thanks for the answer!

My code is exactly as yours (The missing "</" parts were removed by the forum engine when I posted).

The problem is that the template works if I omit the t-foreach loop, displaying a page with only the Back button visible. As soon as I include the foreach part, then I get an 'undefined' error in my console. I've used the most simplified qweb t-foreach loop. It doesn't work. Neither does any other t-foreach loop (in the specific xml file). I have used many times t-foreach loops in my xml files without any problem. I can't understand why it throws an error now.

I actually followed a tutorial from your blog: https://www.cybrosys.com/blog/how-to-add-custom-screens-in-the-odoo-16-pos

The example I present here is a simplified version, just to present the problem I'm facing.

Panos Anagnostakis
Autor

I just realized I can't use t-foreach, anywhere in POS xmls. It works in q-web reports, but not in POS screens or POS screen elements.

¿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
I trying to acess the model record in Java script in odoo 17 Resuelto
javascript pos owl v17
Avatar
Avatar
Avatar
Avatar
3
mar 25
9387
Select Customer before creating order pos odoo 16
javascript pos owl odoo16features
Avatar
0
ene 24
2368
How can I inherit or extend a OWL class and add a new function or override a function on it? Resuelto
javascript pos owl v15
Avatar
Avatar
2
sept 23
10764
Max allowed quantity in pos
javascript pos xml odoo10.0
Avatar
0
sept 20
38
How to hide/show custom button based on condition in odoo10 Point of sale ? Resuelto
javascript pos xml odoo10.0
Avatar
Avatar
Avatar
4
may 18
13871
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