Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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

Avatar
Verwerfen
Autor Beste Antwort

Here's the solution that worked for me


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




Avatar
Verwerfen
Beste Antwort

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

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Jan. 23
4845
1
Juni 22
3161
1
Mai 22
3449
1
Dez. 21
2761
4
März 25
51791