Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
1940 Visualizzazioni

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
Abbandona
Autore Risposta migliore

Here's the solution that worked for me


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




Avatar
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
gen 23
4816
1
giu 22
3128
1
mag 22
3414
1
dic 21
2740
4
mar 25
51564