From ee4c67dc10acf168e446d3cd8b56eb07fa1fef2b Mon Sep 17 00:00:00 2001 From: Martin Trigaux <mat@openerp.com> Date: Mon, 22 Sep 2014 12:16:46 +0200 Subject: [PATCH] [FIX] account_voucher: convertion rate of purchase receipt The conversion of currencies in vouchers are made based on payment_rate_currency_id field (instead of usual currency_id). This field was not present in the purchase view and not correctly set when we change the journal (and thus the currency) which was leading to rates of 1. With a rate of 1, the amount is equal to the currency amount (which is rarely correct). opw 611254 --- addons/account_voucher/account_voucher.py | 2 +- addons/account_voucher/voucher_sales_purchase_view.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 4b19ae6b8240..25046a68ed61 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -918,7 +918,7 @@ class account_voucher(osv.osv): currency_id = journal.currency.id else: currency_id = journal.company_id.currency_id.id - vals['value'].update({'currency_id': currency_id}) + vals['value'].update({'currency_id': currency_id, 'payment_rate_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. diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 2dd53832529d..20ac768258c0 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -222,6 +222,7 @@ <field name="pay_now" invisible="1"/> <field name="type" invisible="True"/> + <field name="payment_rate_currency_id" invisible="1"/> <group> <group> <field name="partner_id" domain="[('supplier','=',True)]" string="Supplier" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, context)" context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}" /> -- GitLab