Odoo Help


Qweb decimal point in reports

Erhuvwu Akpobaro
on 1/22/15, 9:36 AM 10,917 views

Hello i have created a custom module , and i dsplay the fields in a qweb report which i also created , the problem is when i look at the module i a normal list view data shows correctly like :

deposit :45.00

How ever if print the custom report : the data shown is 45.0

here is an example of my modules code :

from openerp.osv import fields,osv
from openerp import tools
class cm_rental_contracts(osv.osv):
    _name = "cm.rental.contracts"
    _description = "Camden Market Rental Contracts"
    _auto = False
    _columns = {
                 'post_code':fields.char('Post Code'),
                 'sale_items':fields.char('Items of Sale'),
                 'service_charge':fields.char('Service Charge'),
                 'contract_category':fields.char('Contracts Category'),
                 'start_date':fields.date('Start Date'),
                 'invoicing_company':fields.char('Invoicing Company'),
                 'invoicing_company_number':fields.char('Invoicing Company Number')


here is an example of a line of in my qweb report in which calls data from my module and displays it :

 <font t-field ="o.rent" face="Arial, serif">:</font>


Is there any way to fix this ?





| 5 3 8
Delhi, India

Nothing to say .... :)

On 8/21/15, 3:38 PM

You can use python for format your decimal numbers. "t-esc" attribute in qweb allows you to write python code, eg:

<span t-esc="'%.2f'%(t.amount)"/></span> 

You can add some computation as well

<span t-esc="'%.2f'%(t.amount * 100)"/></span>

This will print value to exactly two decimal places



| 6 5 7
Lodz, Poland

On 1/22/15, 10:06 AM

Try simmilar to (o.currency_id is mandatory):

<span t-field="o.deposit" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>

Erhuvwu Akpobaro
On 1/22/15, 11:24 AM

Thanks guys , for the help both examples worked .

If worked, you vote and/or accept good answer or answers.

on 1/22/15, 12:09 PM

Kazim Mirza

--Kazim Mirza--
--Kazim Mirza--
Kazim Mirza
On 1/22/15, 10:02 AM

Hello Erhuvwu Akpobaro

You need to import 
import openerp.addons.decimal_precision as dp

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

Thank You



About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/22/15, 9:36 AM
Seen: 10917 times
Last updated: 8/21/15, 3:40 PM