Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

[Odoo SH] How to order by child fields ?

Suscribirse

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

Se marcó esta pregunta
pythonxmlqwebOdooSH
1 Responder
3303 Vistas
Avatar
florent.uagolf@gmail.com

Hi !


I'm doing a search to create a qweb page displaying products and size variants.
I want to have variants sorted by attribute sequence !!
the query in .py file :
produits=request.env['product.template'].search([],0,200,'id desc ')

in Xml views, I unsuccessfully tried :
<t t-set="attribute" t-value="my_query.product_variant_ids" t-options="{'order by': 'sequence'}"/>
and I use a loop to display them

<t t-foreach="attribute" t-as="size">

Can anyone explain how to do it

0
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

Hi,

We are also directly using a sorted function in the XML 

Can you please try with the following syntax for sorting by attributes sequence?

<t t-foreach="my_query.product_variant_ids.sorted(key=lambda m: m.attribute_id.sequence)" t-as="size" >

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

1
Avatar
Descartar
florent.uagolf@gmail.com
Autor

Hi !

Thanks a lot for your interest !

Nice that the lambda sort works directly !!

I tried your code, but maybe I don't really know where to use it, as I use a <t t-set in place of your foreach.

So I didn't on which foreach I should write your code ?

First I have a foreach named "toto" that display the product request from my class in .py file.

In second I have a foreach named "tutu" to display all the variants for each product (in the last try I wrote the sorting code here)

But wherever I write this code I have a qweb error !?

Here is my full code with the sort code (so not working) :

<table border="0">

<t t-foreach="produits" t-as="toto">

<tr bgcolor="#FFF7F7">

<th nowrap="nowrap"></th>

<th coslpan="2" valign="bottom"><P t-esc="toto.name"/></th>

<th><t t-esc="toto.list_price"/> € / <strike><t t-esc="toto.x_studio_pvpc_eur"/> €</strike></th>

</tr>

<tr>

<td><span t-field="toto.image_128" t-options="{'widget': 'image', 'preview_image': 'image_1024' if product_image_big else 'image_128'}" width="50" class="d-flex h-50 justify-content-center align-items-center"/></td>

<td>

<table border="0">

<tr>

<t t-set="attribute" t-value="toto.product_variant_ids"/>

<t t-set="index_i" t-value="1"/>

<t t-foreach="attribute.product_variant_ids.sorted(key=lambda m: m.attribute_id.sequence)" t-as="tutu">

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

<tr bgcolor="#FFF7F7"></tr>

</t>

<td><table><tr><td bgcolor="#FFF7F7"><t t-esc="tutu.product_template_attribute_value_ids.name" class=""/></td><td bgcolor="#FEFBFB"><font size="xsmall"> : <t t-if="int(tutu.qty_available)&lt;=0"><font color="brown"> 0 </font></t><t t-else=""><font color="green"> <t t-esc="int(tutu.qty_available)"/></font></t> </font> <t t-set="index_i" t-value="index_i+1"/></td></tr><tr><td colspan="2"><input type="text" size="3" value="0"></input><input type="hidden" size="3" value="tutu.default_code"></input></td></tr></table>

</td>

</t>

</tr>

</table>

Thanks a lot !

florent.uagolf@gmail.com
Autor

Hi !

Can't make it work, I have object has no attribute 'sequence'

Thansk a lot !

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
missing headers, footers and CSS layout (i.e. are ugly) on server. Odoo v8 Resuelto
python xml qweb
Avatar
1
oct 15
5454
Report text and header is overlaps when description is too long in QWeb report Invoice / Odoo 17
python xml qweb report odoo17
Avatar
0
sept 25
1943
t-att-href url get error Resuelto
xml qweb
Avatar
Avatar
2
abr 23
9705
How to change total amount in purchase qweb report ' , ' in odoo for different currency
purchase python xml qweb v14
Avatar
Avatar
1
abr 23
4619
How to hide view.xml fields group in Account module with attr
python xml
Avatar
Avatar
Avatar
2
dic 23
13955
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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