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,