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

[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
14531 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.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How is Qweb2 can not find and load templates? Resuelto
qweb2
Avatar
Avatar
Avatar
2
dic 23
25397
How to set the specific field to invisible in printed report Resuelto
t-field
Avatar
Avatar
1
ene 20
5739
Show div based on Boolean condition Resuelto
boolean t-if
Avatar
Avatar
1
oct 25
459
why it is not working in qweb template
reporting t-if
Avatar
Avatar
Avatar
2
jun 24
2076
How to use a t-if for a field of a linked object?
odooV8 t-if
Avatar
0
oct 23
1974
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