Skip to Content
Menu
This question has been flagged
6 Replies
2876 Views

Hi everyone,

How to convert amount to words in odoo9.0?

Here Eg :428,782.50 this is the total amount then
Four Hundred Twenty-Eight Thousand, Seven Hundred Eighty-Two and Fifty Paisa showing like the way..
Our requirement is four lakh twenty thousand seven hunded eighty two and fifty paisa it should show.



Avatar
Discard
Best Answer

Hello Savitha,

To get it in lakhs instead of millions, you can use the following code.

first install the num2words,

sudo pip install num2words

Then import it,

from num2words import num2words
am= num2words(424442, lang='en_IN')
print "amount in words......", am

Thanks

Avatar
Discard
Author Best Answer

Hi everyone,

I got the solution.

from num2words import num2words

text_amount = fields.Char("Text Amount:", size=100)

@api.onchange('amount_total')
    def onchange_amount_total(self):
        test_val = num2words(self.amount_total, lang='en_IN')
        new_am = test_val.replace(' and ', ' ')
        new_am1 = new_am.replace('point', 'rupees and')
        self.text_amount = (new_am1 + ' paisa only').capitalize()

Thanku

Avatar
Discard
Best Answer

Hello,

Try this

import math

to convert field amount to words

amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
amount_in_words = amount_in_words.replace(' and Zero Cent', '')


Avatar
Discard
Author

No its showing ans as only "Zero"

Author

yes i checked but iam getting same issue.

Total-25,715,758.78

Amt in words -Twenty-five million, seven hundred fifteen thousand, seven hundred fifty-eight rupees and seventy-eight paise only