Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
8209 Zobrazení

Hello 

How can i add a line with the amount in text in the invoice please? i have the entreprise cloud edition 12. 

Thank you for your help.

Avatar
Zrušit
Nejlepší odpověď

You need to add new computed text field in invoice line. There is default function in currency class that convert amount to text. You nedd to call that function with amount parameter. 

self.currency_id.amount_to_text(self.amount)
Avatar
Zrušit
Autor

Hi thank you for your help but can you be more specific on how to do this in odoo Studio

Nejlepší odpověď
from openerp.tools.amount_to_text_en import amount_to_text
define a computed_field.
amount_to_text = fields.Char(string='Amount In Text', compute='convert')
define compute function.
@api.multi
def convert(self):
"""

:param self:
:return:
"""
for record in self:
currency_id = self.env.user.company_id.currency_id.id
record.amount_to_text = self._amount_to_text(record.amount,currency_id)
def _amount_to_text(amount, currency_id):
# Currency complete name is not available in res.currency model
# Exceptions done here (EUR, USD, BRL) cover 75% of cases
# For other currencies, display the currency code
currency = self.env['res.currency'].browse(currency_id)
if currency.name.upper() == 'EUR':
currency_name = 'Euro'
elif currency.name.upper() == 'USD':
currency_name = 'Dollars'
elif currency.name.upper() == 'BRL':
currency_name = 'reais'
else:
currency_name = currency.name
#TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
#amount_in_word = amount_to_text(amount, context=context)
return amount_to_text(amount, currency=currency_name)


Avatar
Zrušit
Nejlepší odpověď

you can do it In the studio add new field (char)

click on more >  Compute > add these line of code 

for rec in self:
currency = rec.currency_id.with_context(lang='YOU LANG CODE')
amount_text = str(currency.amount_to_text(rec.amount_total))
rec['x_studio_amount_in_word'] = amount_text


Avatar
Zrušit
Nejlepší odpověď

Hello,

get a free module: https://apps.odoo.com/apps/modules/12.0/jt_amount_in_words/

Avatar
Zrušit
Autor

Sorry can't do that as i can't use third party modules in Odoo entreprise cloud

ok no problem, but you can copy code from module and add to your cloud module