Odoo Help


How to convert number to word in oddo?

on 11/14/15, 2:41 AM 2,532 views

I want to convert amount_total in invoice to words in Indian rupees. I tried like this,

In .py file,

class account_invoice(models.Model): 
_inherit = "account.invoice"
def amount_to_text(self, amount, currency='rupee'):
    return amount_to_text(amount, currency)

In report,

 <strong><td>Total in words:</td></strong> 
<span t-esc="o.amount_to_text(o.amount_total, o.currency_id)"/>

But still it is coming in euros

Axel Mendoza
On 11/15/15, 8:02 AM

I recommend to use num2words library:


Here is an example using it with Spanish and it supports indian too.

from num2words import num2words
pre = float(value)
text = ''
entire_num = int((str(pre).split('.'))[0])
decimal_num = int((str(pre).split('.'))[1])
if decimal_num < 10:
decimal_num = decimal_num * 10
text+=num2words(entire_num, lang='es')
text+=' con '
text+=num2words(decimal_num, lang='es')
print text

You can use it directly like:

text = num2words(value, lang='en_IN')

But the first example provides a better monetary approach


on 11/16/15, 1:58 AM

Hey if i try this on python IDE it works perfectly but on odoo report it comes blankclass account_invoice(models.Model): _inherit = "account.invoice" @api.one def _print_amount(self): print "Hello world" value=self.amount_total print value pre = float(value) text1 = '' text2 = '' result = '' entire_num = int((str(pre).split('.'))[0]) decimal_num = int((str(pre).split('.'))[1]) if decimal_num

on 11/16/15, 6:40 AM
Drees Far
On 11/15/15, 3:01 PM

Hello my friend;

1.here is how you can convert your amount_total to the available currency:

import urllib2

import json

def currencyConverter(currency_from,currency_to,currency_input):

yql_base_url = "https://query.yahooapis.com/v1/public/yql"

yql_query = 'select * from yahoo.finance.xchange where pair in ("'+currency_from+currency_to+'")'

yql_query_url = yql_base_url + "?q=" + yql_query + "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"


yql_response = urllib2.urlopen(yql_query_url)


yql_json = json.loads(yql_response.read())

currency_output = currency_input * float(yql_json['query']['results']['rate']['Rate'])

return currency_output

except (ValueError, KeyError, TypeError):

return "JSON format error"

except IOError, e:

if hasattr(e, 'code'):

return e.code

elif hasattr(e, 'reason'):

return e.reason

###### in the currency_input you will put your amount_total that you have got in euros###

currency_input = 1

currency_from = "EUR" # currency codes : http://en.wikipedia.org/wiki/ISO_4217

currency_to = "INR"

rate = currencyConverter(currency_from,currency_to,currency_input)

print rate

2.And then to have the amount_total in word you will use this:

Use pynum2word module that can be found at sourceforge
>>> import num2word
>>> num2word.to_card(15)
>>> num2word.to_card(55)
>>> num2word.to_card(1555)

'one thousand, five hundred and fifty-five'

here is a useful link to this part:


Best regards.

Hey,thanks for the answer but i used answer provided by Dress as it as very simpler

on 11/16/15, 1:59 AM

Hey,thanks for the answer but i used answer provided by Axel as it as very simpler

on 11/16/15, 2:01 AM

i don't have enough karma to edit comments

on 11/16/15, 2:01 AM
On 9/5/16, 11:53 AM

hi , i had download module 'pynum2word' but it isnt working for me

please tell me how to use it i want to convert number to letters how to integrate it in my module


Ahmed M.Elmubarak
On 11/14/15, 5:15 AM


Kindly check these .py files: amount_to_text_en, amount_to_text 


You can also check this questions


I want in rupees, but if i use this i will get in euros

on 11/14/15, 5:59 AM

I edited my answer, If this not helped you please add more details to your question ...

Ahmed M.Elmubarak
on 11/14/15, 6:08 AM

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

2 follower(s)


Asked: 11/14/15, 2:41 AM
Seen: 2532 times
Last updated: 9/5/16, 11:53 AM