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

How to format numbers in Qweb Reports - OdooV8

Suscribirse

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

Se marcó esta pregunta
qwebformatreportodooV8
6 Respuestas
23420 Vistas
Avatar
Matjaz

Hello,

I have a problem with number formatting in qweb reports.

I have set Decimal Accuracy in settings and numbers are in correct format if defined as "t-field". If you need to calculate result or call a function you need to do it with "t-esc" and in this case numbers are not in correct format.

I saw you can use "formatLang" as in RML reporting, but you have to wrap old RML parser with Qweb one as in "report_payslip". But isn't this nonsense. Throwing away RML reporting in behalf of Qweb and now wrapping it again?

What will happen in Odoo 9, will this solution work also (as I know there will be no support for RML)?

What can be done? Call a function and format a number on 'python' side or is there some other solution?


Thanks for any info or advise,

Matjaž

1
Avatar
Descartar
Avatar
Rucha Dave (rda)
Mejor respuesta

Hello Matjaz,

by default we are using,

<span t-field="o.amount" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.pricelist_id.currency_id&quot;}"/>

it will automatically set system decimals.


To change "." to "," , use replace function, 

for example,   <span t-esc="(o.amount).replace('.', ',')"/> 

It's working correct from my side.

I hope, it will be clear to you, and correct me if still I misunderstood your concern.


Regards,

5
Avatar
Descartar
Matjaz
Autor

First of all your solution doesn't print Thousands Separator and decimal Separator is also wrong. We have ',' for Decimal Separator and '.' for Thousands Separator. in your way number 3548.07 is displayed as 3548.07 but should be 3.548,07. Secondly with your solution you predefine number of decimal places, but number should be taken from the system....

Rucha Dave (rda)

I have updated my answer. please check :)

Matjaz
Autor

Thank you for an answer, but no, it's not working as expected. If you use "t-field" is OK, value is being formatted with thousand separator and correct character separator. Using "t-esc" value is not formatted at all. In your "t-esc" example (you forgot to transform float to string), there is no thousand separator and also decimal/thousand separators are fixed and not being pulled from the system. For example: you have several partners that have different decimal/thousand separators..

Avatar
Jan Schlenker
Mejor respuesta

In Odoo 10 I had the same problem and solved it in a similiar fashion. I orientated myself by the function formatLang() of the misc.py file: https://github.com/odoo/odoo/blob/10.0/odoo/tools/misc.py.

Model:

class AccountInvoice(models.Model):
    _inherit = 'account.invoice'

    def _formatLang(self, value):
        lang = self.partner_id.lang
        lang_objs = self.env['res.lang'].search([('code', '=', lang)])
        if not lang_objs:
            lang_objs = self.env['res.lang'].search([], limit=1)
        lang_obj = lang_objs[0]

        res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
        currency_obj = self.currency_id;

        if currency_obj and currency_obj.symbol:
            if currency_obj.position == 'after':
                res = '%s %s' % (res, currency_obj.symbol)
            elif currency_obj and currency_obj.position == 'before':
                res = '%s %s' % (currency_obj.symbol, res)
        return res

QWeb:

<span t-esc="o._formatLang(amount_by_group[1])"/>
0
Avatar
Descartar
Avatar
Matjaz
Autor Mejor respuesta

Because there is NO solution about formatting numbers and no answer regarding wrapping RML reports, my solution is a function inside report py file which can be called from Qweb reports. You can select number of decimal points (default is two) and display currency symbol if you pass in the currency object. Function is a mix of code from ir_qweb.py (class FloatConverter and class MonetaryConverter). If someone has a kind of direct solution or can do better coding please....


class report_invoice(models.AbstractModel):

_name = 'report.account.report_invoice'

def convert_2float(self, value, precision=2, currency_obj=None, context=None):

    fmt = '%f' if precision is None else '%.{precision}f'

    lang_code = self.env.context.get('lang') or 'en_US'

    lang = self.pool['res.lang']

    formatted = lang.format(self.env.cr, self.env.uid, [lang_code], fmt.format(precision=precision), value, grouping=True,     monetary=True)

    if currency_obj:

    if currency_obj.position == 'before':

        formatted = currency_obj.symbol + ' ' + formatted

    else:

        formatted = formatted + ' ' + currency_obj.symbol

    return formatted


@api.multi

def render_html(self, data=None):

report_obj = self.env['report']

report = report_obj._get_report_from_name('account.report_invoice')

docargs = {

    'convert_2float': self.convert_2float,

     'doc_ids': self._ids,

    'doc_model': report.model,

    'docs': self,

    }

return report_obj.render('account.report_invoice', docargs)


And the call from Qweb:

<span t-esc="convert_2float((o.amount_total - o.residual),2,o.currency_id)"/>

0
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
How to restrict user to save print report in their local system?
qweb report odooV8
Avatar
0
dic 17
4387
How to dynamically change report Name odoo v8
qweb report odooV8
Avatar
Avatar
1
sept 17
5863
How to create report (fields based on existing model)
qweb report odooV8
Avatar
Avatar
2
feb 17
8058
How to change footer position/height in qweb reports ? Resuelto
qweb report odooV8
Avatar
Avatar
1
ago 16
17627
Vertical header in invoice and sale_order reports
qweb report odooV8
Avatar
0
ene 16
3951
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