Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to format numbers in Qweb Reports - OdooV8

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
qwebformatreportodooV8
6 Antworten
23421 Ansichten
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
Verwerfen
Avatar
Rucha Dave (rda)
Beste Antwort

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
Verwerfen
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
Beste Antwort

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
Verwerfen
Avatar
Matjaz
Autor Beste Antwort

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
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
How to restrict user to save print report in their local system?
qweb report odooV8
Avatar
0
Dez. 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 ? Gelöst
qweb report odooV8
Avatar
Avatar
1
Aug. 16
17627
Vertical header in invoice and sale_order reports
qweb report odooV8
Avatar
0
Jan. 16
3951
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Ausbildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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