问题
enter image description hereI want to convert the total amount showing in account invoice to word, please help. I could not solve it. Also I already tried to it but no luck
回答1:
Did you want it in your report or for your record ?
For Report
In Odoo10 I usually do like this:
<t t-esc="o.amount_total" t-esc-options='{"widget": "num2words","case":"capital"}'/>
Here we have to install num2words module for its correct working. You can install it by
pip install num2words
or just google.
回答2:
You can use following method for your problem.
def Numbers_To_Words (number):
dictionary = {'1': "one", '2': "two", '3': "three", '4': "four", '5': "five", '6': "six",
'7': "seven", '8': "eight", '9': "nine", '0': "zero"}
return " ".join(map(lambda x: dictionary[x], str(number)))
print Numbers_To_Words(1234)
回答3:
There is num2words module in python install pip install num2words
num2words
from num2words import num2words
@api.multi
def numtoword_s(self, amount_total):
return (num2words(amount_total, lang='en_IN')).title()+" only"
create this function in invoice file and call the application from qweb pass the amount you want to convert into text format.
回答4:
May be this will help you out : https://www.daniweb.com/programming/software-development/code/216839/number-to-word-converter-python
Also this one too :https://pypi.org/project/inflect/ This is a py lib which represent your number into relevant words
来源:https://stackoverflow.com/questions/53029729/amount-in-text-odoo-10