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

Why does this line not work in the sale order qweb template?

Suscribirse

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

Se marcó esta pregunta
qwebtemplatesale.order
2 Respuestas
12953 Vistas
Avatar
Pascal Tremblay

Hello all,

On the template sale.report_saleorder_document in Odoo 10 enterprise.

One line causes an error, and I don't find the problem. It is weird because this line works on an other Odoo 10 installation.

These lines works well :

<span t-field="l.price_subtotal" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}' />
<span t-field="l.price_total" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}' />
<span t-esc="subtotal" t-options="{'widget': 'monetary', 'display_currency': doc.pricelist_id.currency_id}" />

But this one doesn't work :

<span t-esc="amount_by_group[1]" t-options="{'widget': 'monetary', 'display_currency': doc.pricelist_id.currency_id}" />

I get this error :

QWebException: unsupported operand type(s) for /: 'unicode' and 'float'
Traceback (most recent call last):
  File "/opt/odoo/addons/base/ir/ir_qweb/qweb.py", line 315, in _compiled_fn
    return compiled(self, append, values, options, log)
  File "<template>", line 1, in template_sale_report_saleorder_document_1191
  File "<template>", line 3, in body_call_content_1190
  File "<template>", line 136, in foreach_1172
  File "/opt/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 276, in _get_widget
    content = converter.value_to_html(value, field_options)
  File "/opt/odoo/addons/base/ir/ir_qweb/fields.py", line 322, in value_to_html
    formatted_amount = lang.format(fmt, display_currency.round(value),
  File "/opt/odoo/addons/base/res/res_currency.py", line 93, in round
    return tools.float_round(amount, precision_rounding=self.rounding)
  File "/opt/odoo/odoo/tools/float_utils.py", line 52, in float_round
    normalized_value = value / rounding_factor # normalize
TypeError: unsupported operand type(s) for /: 'unicode' and 'float'
Error to render compiling AST
TypeError: unsupported operand type(s) for /: 'unicode' and 'float'
Template: sale.report_saleorder_document
Path: /templates/t/t/div/div[3]/div/table/t/tr/td[2]/span
Node: <span t-esc="amount_by_group[1]" t-options="{'widget': 'monetary', 'display_currency': doc.pricelist_id.currency_id}"/>
-1
Avatar
Descartar
Avatar
Hilar Andikkadavath
Mejor respuesta

Hi,

Please check the values returned by _get_tax_amount_by_group , I think ie unicode or string, not float.

this is the code that fetches amount_by_group

<t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">    ...


python function _get_tax_amount_by_group() returns;

res = map(lambda l: (l[0].name, formatLang(self.env, l[1], currency_obj=currency)), res)
return res
1
Avatar
Descartar
Pascal Tremblay
Autor

Thanks for your precious answers! Have a good day!

Avatar
Pascal Tremblay
Autor Mejor respuesta

In my Odoo 10 on which I do my tests :

We have this in account_invoice and sale_order _get_tax_amount_by_group :

res = map(lambda l: (l[0].name, l[1]), res)

So, these lines work well in sale orders and invoices :

<span t-field="doc.amount_total" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}' />
<span t-esc="amount_by_group[1]" t-options='{"widget": "monetary", "display_currency": o.currency_id}' />


On the Odoo 10 enterprise of my customer, the code in Python is not the same, we have this line in account_invoice and sale_order _get_tax_amount_by_group :

res = map(lambda l: (l[0].name, formatLang(self.env, l[1], currency_obj=currency)), res)

So, like mister Hilar said, this line will be sufficient in sale orders and invoices PDF report :

<span t-esc="amount_by_group[1]"  />
1
Avatar
Descartar
¿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
AssertionError: Element odoo has extra content: template, line 5 Resuelto
qweb template
Avatar
Avatar
1
ene 19
9613
Custom background
qweb template odoo17
Avatar
0
dic 24
2031
Odoo 11 - I cannot get context on QWeb Template
qweb template context
Avatar
0
dic 24
1863
How to pass multiple variable to template with t-call?
qweb template odoo16
Avatar
Avatar
2
jul 24
4501
How to style product description output in sale.order report template?
qweb formatting template
Avatar
Avatar
1
mar 21
4259
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