Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Qweb - Drop trailing 0's after decimal

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
qwebreportingreport
8 Replies
23198 Tampilan
Avatar
Cliff Kujala

How can we format values on Qweb reports to only drop the trailing 0's after the decimal poing in Qweb v8 reports?  Such that 1.0000 would display as 1, 1.5000 would display as 1.5, and 1.5250 would display as 1.525?

Can it be a modification to formatLang(<<your value>>,digits=0)

I want my quantities in Quotes/Sales Orders/Invoice reports to appear like this https://www.purekarting.com/odoo/lightspeedinvoice.pdf instead of how they are currently like this https://www.purekarting.com/odoo/sale.report_saleorder.pdf

0
Avatar
Buang
Avatar
Cyrus Waithaka
Jawaban Terbai

Qweb allows you to run python expressions using t-esc and t-raw tags. This should therefore work: 

t-esc="int(float(l.quantity))"

I hope this helps.

5
Avatar
Buang
Avatar
Stephen Mack
Jawaban Terbai

Don't believe there is code to do that.  You will probably need to write some code to handle the special formatting you require.

How about trying this piece of coding based on the text of your question/answer:

<t t-set="mod_qty">
    formatLang(l.product_uom_qty, digit=0)
</t>

<t t-if="mod_qty == l.product_uom_qty">
    <t t-esc="mod_qty" />
</t>

<t t-if="mod_qty != l.product_uom_qty">
    <t t-esc="(l.product_uom_qty * 1)" />
</t>

Or this generic code that will print your list of numbers.

<t t-foreach="[3.000, 3.050, 3.005, 3.0005]" t-as="my_qty">
    <t t-set="mod_qty">
        formatLang(my_qty, digit=0)
    </t>

    <t t-if="mod_qty == my_qty">
        <p><t t-esc="mod_qty"/></p>
    </t>

    <t t-if="mod_qty != my_qty">
        <p><t t-esc="(my_qty * 1)"/></p>
    </t>
</t>

1
Avatar
Buang
Avatar
Cliff Kujala
Penulis Jawaban Terbai

I've gotten closer.

https://www.purekarting.com/odoo/sale.report_saleorder_closer.pdf

By using <t t-esc="(l.product_uom_qty * 1)" />, it converts the qty from a string to a number.  Trailing zeros past the first decimal precision are dropped in numbers.

So, seeing as how I have decimal precision set to 3 on product_uom_qty, values will be reported as:

3.000 prints as 3.0
3.050 prints as 3.05
3.005 prints as 3.005
3.0005 is rounded up by Odoo to 3.001, and then prints as 3.001

Close but not perfect.  I'd like to drop that trailing .0 from the whole number quantities still.

0
Avatar
Buang
Stephen Mack

Why not handle that case in an if statement. Test to see if you have a whole number and then use formatLang to remove the zeros just for whole numbers. Seems you have everything else covered.

Cliff Kujala
Penulis

Any idea how to check if whole number? IF WHOLE IF NOT THEN THIS FOR w/ Decimals I've also ready through this: https://www.odoo.com/documentation/master/reference/qweb.html There is simply no detailed documentation on writing the conditionals. I also wonder if the decimal trim can't just be done with a t-field-options setting, in the same way we format date fields on reports. However, I can't find the documentation explaining the t-field-options which are available for each specific field. From the Qweb documentation: t-field-options can be used to customize fields, the most common option is widget, other options are field- or widget-dependent.

Stephen Mack

why cant you truncate it to a whole number in formatLang then test it against the original value. If they are equal then it is a whole number and you print the truncated number if not then you print your formatted decimal.

Stephen Mack

I have updated my answer above. Give that a try.

Avatar
Erhuvwu Akpobaro
Jawaban Terbai

what you could  do is :

import openerp.addons.decimal_precision as dp

and also  for example this will allow your field to acces the decimal accuary of account so if you set account to have 8 decimal places your field will have 8 decimal places:

'rent':fields.float('Rent',digits_compute= dp.get_precision('Account')), 

 

 

 

-1
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
[SOLVED]Retrieving the product template linked to a variant selected in treeview Diselesaikan
qweb reporting report
Avatar
Avatar
Avatar
3
Mar 18
8770
How to generate custom report with custom data from a wizard? v16 Diselesaikan
qweb reporting report odoo16features
Avatar
Avatar
1
Mei 24
4460
How to add the order number in the footer (QWEB)
qweb reporting report odoo10
Avatar
0
Jul 17
4355
odoo 16 report target new page scss
qweb report
Avatar
Avatar
1
Apr 25
2167
Missing external identifier on new external layout template Diselesaikan
qweb report
Avatar
Avatar
2
Mar 25
2746
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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