From b507941664709dbd1f8da15e5d5944d1fb2342c2 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 25 Apr 2013 14:44:04 +0200 Subject: [PATCH] [FIX] account_voucher: usability improvement related to multi currency bzr revid: qdp-launchpad@openerp.com-20130425124404-t22dzpv0rtohoh9y --- addons/account_voucher/account_voucher.py | 19 +++++++------------ .../voucher_payment_receipt_view.xml | 6 +++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 6d0e8c6130b..d65b7ee2bb1 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -225,24 +225,19 @@ class account_voucher(osv.osv): def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount, voucher_currency, type, context=None): context = context or {} if not line_dr_ids and not line_cr_ids: - return {'value':{}} + return {'value':{'writeoff_amount': 0.0, 'is_multi_currency': False}} line_osv = self.pool.get("account.voucher.line") line_dr_ids = resolve_o2m_operations(cr, uid, line_osv, line_dr_ids, ['amount'], context) line_cr_ids = resolve_o2m_operations(cr, uid, line_osv, line_cr_ids, ['amount'], context) #compute the field is_multi_currency that is used to hide/display options linked to secondary currency on the voucher is_multi_currency = False - if voucher_currency: - # if the voucher currency is not False, it means it is different than the company currency and we need to display the options - is_multi_currency = True - else: - #loop on the voucher lines to see if one of these has a secondary currency. If yes, we need to define the options - for voucher_line in line_dr_ids+line_cr_ids: - company_currency = False - company_currency = voucher_line.get('move_line_id', False) and self.pool.get('account.move.line').browse(cr, uid, voucher_line.get('move_line_id'), context=context).company_id.currency_id.id - if voucher_line.get('currency_id', company_currency) != company_currency: - is_multi_currency = True - break + #loop on the voucher lines to see if one of these has a secondary currency. If yes, we need to see the options + for voucher_line in line_dr_ids+line_cr_ids: + line_currency = voucher_line.get('move_line_id', False) and self.pool.get('account.move.line').browse(cr, uid, voucher_line.get('move_line_id'), context=context).currency_id + if line_currency: + is_multi_currency = True + break return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount, type), 'is_multi_currency': is_multi_currency}} def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 3cdd93c8d20..a16730098c9 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -157,7 +157,7 @@