Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1950 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Here's the solution that worked for me


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




Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 1 23
4830
1
thg 6 22
3151
1
thg 5 22
3436
1
thg 12 21
2753
4
thg 3 25
51665