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
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

[Odoo10] QWeb t-if

Suscribirse

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

Se marcó esta pregunta
unitsqweb2t-ift-field
2 Respuestas
14525 Vistas
Avatar
Maxime MARAIS

Hi all,

On our Odoo instance, some articles are in kilograms, litters and units. We may sometime order/sale a few milliliters or grams of some articles. The Decimal Accuracy setting was adjusted to 4 digits for Product Unit of Measure. The drawback is that for articles in "Units", all values expected to be integers are also displayed with 4 digits after decimal. Ex. 20.0000 carrots for 20 carrots. For internal use, that's not a really issue. Nevertheless, be become an issue when dealing with order forms, invoices, etc.

To address this issue, I undertook to develop an add-on to modify the report_saleorder_document QWeb report defined for the template named sale.report_saleorder to display l.product_uom_qty as an integer when l.product_uom is set to "Unit(s)", else as a float.

My template.xml looks like :

<template id="report_saleorder_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//span[@t-field='l.product_uom_qty']" position="replace">
<t t-set="unit" t-value="l.product_uom"/>
[<t t-esc="unit" />]
<span t-if="unit == 'product.uom(1,)'" t-esc="int(l.product_uom_qty)"/>
<span t-else="" t-field="l.product_uom_qty"/>
<!-- <span t-field="l.product_uom" groups="product.group_uom"/> -->
</xpath>
</template>

This display [product.uom(1,)] for [<t t-esc="unit" />]

But the test t-if="unit == 'product.uom(1,)'" fails. It seems QWeb tries to interpret/execute product.uom(1,) as it would do for any other function and do not use it as a literal string.

Would you have a solution in order address this simple need : display quantity as an integer when articles is in Units, display as a regular float else?

Thanks.

Maxime.

0
Avatar
Descartar
Avatar
Fatih Piristine
Mejor respuesta

 try:

<template id="report_saleorder_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//span[@t-field='l.product_uom_qty']" position="replace">
         <t t-if="int(l.product_uom) == 1"> <!-- id of Unit(s) -->
             ...
         </t>
         <t t-if="int(l.product_uom) != 1">
             ...
         </t>
</template>

0
Avatar
Descartar
Avatar
Maxime MARAIS
Autor Mejor respuesta

Hi F.P.

Finally I gave up for an easier solution :

<span t-if="int(l.product_uom_qty) == l.product_uom_qty" t-esc="int(l.product_uom_qty)"/>
<span t-else="" t-field="l.product_uom_qty">

After all displaying 2.0000 L is the same as 2 L. But I'll try your solution too, it may be useful.

Thanks.

0
Avatar
Descartar
Fatih Piristine

there is uom_coeff column causing that 0000... have a look that one.

¿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
How is Qweb2 can not find and load templates? Resuelto
qweb2
Avatar
Avatar
Avatar
2
dic 23
25392
How to set the specific field to invisible in printed report Resuelto
t-field
Avatar
Avatar
1
ene 20
5729
Show div based on Boolean condition Resuelto
boolean t-if
Avatar
Avatar
1
oct 25
454
why it is not working in qweb template
reporting t-if
Avatar
Avatar
Avatar
2
jun 24
2070
How to use a t-if for a field of a linked object?
odooV8 t-if
Avatar
0
oct 23
1968
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