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 @@