From 9b01552b79e67af818c96b37f292b7f2d26fc8ef Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 13 May 2013 16:21:16 +0200 Subject: [PATCH] [IMP] account_voucher, usability: reset the amount to 0 in the 'pay invoice wizard' if the currency is not the same than the invoice currency to avoid a common mistake bzr revid: qdp-launchpad@openerp.com-20130513142116-wyuud8n9fcnafc7l --- addons/account_voucher/account_voucher.py | 6 ++++++ addons/account_voucher/invoice.py | 1 + 2 files changed, 7 insertions(+) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index f8b380a7ea4..322d9dab6d5 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -880,6 +880,12 @@ class account_voucher(osv.osv): else: currency_id = journal.company_id.currency_id.id vals['value'].update({'currency_id': currency_id}) + #in case we want to register the payment directly from an invoice, it's confusing to allow to switch the journal + #without seeing that the amount is expressed in the journal currency, and not in the invoice currency. So to avoid + #this common mistake, we simply reset the amount to 0 if the currency is not the invoice currency. + if context.get('payment_expected_currency') and currency_id != context.get('payment_expected_currency'): + vals['value']['amount'] = 0 + amount = 0 res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context) for key in res.keys(): vals[key].update(res[key]) diff --git a/addons/account_voucher/invoice.py b/addons/account_voucher/invoice.py index c0584ddbd52..a38a3d3e9b6 100644 --- a/addons/account_voucher/invoice.py +++ b/addons/account_voucher/invoice.py @@ -41,6 +41,7 @@ class invoice(osv.osv): 'target': 'new', 'domain': '[]', 'context': { + 'payment_expected_currency': inv.currency_id.id, 'default_partner_id': self.pool.get('res.partner')._find_accounting_partner(inv.partner_id).id, 'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual, 'default_reference': inv.name,