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

Qweb : error using a condition to add </tr><tr> to change row inside a foreach

Suscribirse

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

Se marcó esta pregunta
qwebeditornoobxmlviewOdooSH
2 Respuestas
5072 Vistas
Avatar
Hedge

Hi all !

I'll try to be as clear as possible.

I'm creating a web view so creating an xml file.

I have a table to show different size of same product.
But if there is more than 7 I want to create a new row to keep it clear on webpage.
So I have a conditional on the index_i variable (didn't still understood how to use $a_index)
when 7 is reached I want to add "</tr><tr>" to make a new row.
But when updating the module I have an error :"lxml.etree.XMLSyntaxError: expected '>' "

Here is my code :

<table border="1">
                                    <tr>
                                        <t t-set="attribute" t-value="toto.product_variant_ids"/>
                                        <t t-set="index_i" t-value="1"/>
                                        <t t-foreach="attribute" t-as="tutu">
                                            <p t-if="index_i==7">
                                                </tr><tr>             
                                            </p>
                                            <td>
                                                <p t-esc="tutu.display_name"/>
                                            </td>
                                            <t t-set="index_i" t-value="index_i+1"/>
                                         </t>
                                    </tr>
                                </table>


Any idea ?


Thanks a lot !

================  THE SOLUTION : ============

I changed this part of code :
                                            <p t-if="index_i==7">
                                                </tr><tr>             
                                            </p>

by :
                                            <t t-if="index_i==10 or index==5">
                                                <tr></tr>
                                            </t>

note the inversion of <tr></tr>

0
Avatar
Descartar
Avatar
Husain Rangwala
Mejor respuesta

Hello Hedge
May be issue is in </tr><tr> tag because you are closing tag which is not opened yet so update your code.

<table border="1">
                                    <tr>
                                        <t t-set="attribute" t-value="toto.product_variant_ids"/>
                                        <t t-set="index_i" t-value="1"/>
                                        <t t-foreach="attribute" t-as="tutu">
                                            <p t-if="index_i==7">
                                                <tr></tr>             
                                            </p>
                                            <td>
                                                <p t-esc="tutu.display_name"/>
                                            </td>
                                            <t t-set="index_i" t-value="index_i+1"/>
                                         </t>
                                    </tr>
                                </table>

Thanks

0
Avatar
Descartar
Avatar
Hedge
Autor Mejor respuesta

Hi Husain !

Thanks to answer !

In fact the opening <tr> is in line 2.
So when the index rate 7 to create a new line, I close the first row and create a second in line 7.
then I open <td> whatever the index is !

Have a nice day

0
Avatar
Descartar
Husain Rangwala

You can not close </tr> tag like this if you want to close that opening <tr> then you must first close </P> and then </t> tag which is inner tag.

Hedge
Autor

Hi Husain !

Ha ok !? but If I do that my loop will stop ?

Husain Rangwala

Simply you just need to open and close <tr></tr> inside loop.

Remove tr tag from starting.

Hedge
Autor

So the solution was in between ;-) :

I changed this part of code :

<p t-if="index_i==7">

</tr><tr>

</p>

by :

<t t-if="index_i==10 or index==5">

<tr></tr>

</t>

note the inversion of <tr></tr>

¿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
[Odoo SH] How to order by child fields ?
python xml qweb OdooSH
Avatar
Avatar
1
feb 21
3420
How to Override Odoo 17 Template Without Locking Web Editor Blocks (Snippets)?
community qweb editor blocks 17.0
Avatar
0
ago 24
2854
Frontend Editor: disable editing of t-field values
editable qweb editor frontend t-field
Avatar
Avatar
1
dic 20
7240
Qweb Editor problem "Insert blocks" not working + Japanese characters
invoice qweb rml report editor
Avatar
0
ago 15
3990
Odoo 18: Display image from char field containing url in qweb form
qweb
Avatar
Avatar
1
jul 25
3169
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