【发布时间】:2018-10-28 08:38:59
【问题描述】:
enter image description here我想把账户发票上显示的总金额转换成word,请帮忙。我无法解决它。我也已经尝试过了,但没有运气
【问题讨论】:
-
请分享您已经尝试过的确切代码。这使得 stackoverflowers 可以为您提供帮助。
enter image description here我想把账户发票上显示的总金额转换成word,请帮忙。我无法解决它。我也已经尝试过了,但没有运气
【问题讨论】:
您希望它在您的报告中还是记录在案?
报告
在 Odoo10 中,我通常这样做:
<t t-esc="o.amount_total" t-esc-options='{"widget": "num2words","case":"capital"}'/>
这里我们必须安装 num2words 模块才能正常工作。您可以通过
安装它pip install num2words 或只是谷歌。
【讨论】:
您可以使用以下方法解决您的问题。
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)
【讨论】:
python 中有 num2words 模块安装pip install num2wordsnum2words
from num2words import num2words
@api.multi
def numtoword_s(self, amount_total):
return (num2words(amount_total, lang='en_IN')).title()+" only"
在发票文件中创建此函数并从 qweb 调用应用程序传递您要转换为文本格式的金额。
【讨论】:
这可能会帮助你:https://www.daniweb.com/programming/software-development/code/216839/number-to-word-converter-python
还有这个 :https://pypi.org/project/inflect/ 这是一个 py 库,将您的数字表示为相关的单词
【讨论】: