From 36846db2c3d172ceacf1890c40e3040900f93771 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 23 Dec 2013 16:46:31 +0100 Subject: [PATCH] [FIX] account_check_writing: display real currency name on check print Instead of 'Euro' hardcoded. As the currency complete name is not available in res.curreny model, exceptions are made for currencies EUR, USD and BRL, the mosts used currencies for checks (+75% of cases) bzr revid: dle@openerp.com-20131223154631-21oenwn8mxszyo5t --- addons/account_check_writing/account_voucher.py | 14 +++++++++++++- addons/account_check_writing/report/check_print.py | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/account_check_writing/account_voucher.py b/addons/account_check_writing/account_voucher.py index 7a5d12f5cff..f7b35dccacc 100644 --- a/addons/account_check_writing/account_voucher.py +++ b/addons/account_check_writing/account_voucher.py @@ -49,9 +49,21 @@ class account_voucher(osv.osv): if 'value' in default: amount = 'amount' in default['value'] and default['value']['amount'] or amount + # 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.pool['res.currency'].browse(cr, uid, currency_id, context=context) + 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) - amount_in_word = amount_to_text(amount) + amount_in_word = amount_to_text(amount, currency=currency_name) default['value'].update({'amount_in_word':amount_in_word}) if journal_id: allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing diff --git a/addons/account_check_writing/report/check_print.py b/addons/account_check_writing/report/check_print.py index 57360025623..add79fcc35a 100644 --- a/addons/account_check_writing/report/check_print.py +++ b/addons/account_check_writing/report/check_print.py @@ -34,7 +34,6 @@ class report_print_check(report_sxw.rml_parse): 'fill_stars' : self.fill_stars, }) def fill_stars(self, amount): - amount = amount.replace('Dollars','') if len(amount) < 100: stars = 100 - len(amount) return ' '.join([amount,'*'*stars])