Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to format numbers in Qweb Reports - OdooV8

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
qwebformatreportodooV8
6 Replies
23425 Rodiniai
Portretas
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
Portretas
Atmesti
Portretas
Rucha Dave (rda)
Best Answer

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
Portretas
Atmesti
Matjaz
Autorius

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
Autorius

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

Portretas
Jan Schlenker
Best Answer

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
Portretas
Atmesti
Portretas
Matjaz
Autorius Best Answer

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
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Related Posts Replies Rodiniai Veikla
How to restrict user to save print report in their local system?
qweb report odooV8
Portretas
0
gruod. 17
4390
How to dynamically change report Name odoo v8
qweb report odooV8
Portretas
Portretas
1
rugs. 17
5865
How to create report (fields based on existing model)
qweb report odooV8
Portretas
Portretas
2
vas. 17
8059
How to change footer position/height in qweb reports ? Solved
qweb report odooV8
Portretas
Portretas
1
rugp. 16
17631
Vertical header in invoice and sale_order reports
qweb report odooV8
Portretas
0
saus. 16
3959
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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