Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
1993 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 23
4906
1
มิ.ย. 22
3201
1
พ.ค. 22
3496
1
ธ.ค. 21
2828
4
มี.ค. 25
52152