跳至内容
菜单
此问题已终结

I'm using odoo version 15 and I want to convert numbers to text and I tried 

from odoo.tools import amout_to_text_en

but it didn't work for me
I got the error message :

ImportError: cannot import name 'amount_to_text_en' from 'odoo.tools'


I even tried to import the amount_to_text function from odoo.addons.base.models.res_currency but it didn't work as well

形象
丢弃
编写者 最佳答案

Here's the solution that worked for me


def amount_to_text(self, amount, currency):        
​return currency.amount_to_text(amount)




形象
丢弃
最佳答案

Hi,


You can use num2words for converting numbers to text.


from num2words import num2words

#Inside your function,

words = num2words(amount, lang='en')


Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
2
1月 23
4821
1
6月 22
3135
1
5月 22
3417
1
12月 21
2741
4
3月 25
51574