[FIX] account_voucher: convertion rate of purchase receipt
authorMartin Trigaux <mat@openerp.com>
Mon, 22 Sep 2014 10:16:46 +0000 (12:16 +0200)
committerMartin Trigaux <mat@openerp.com>
Mon, 22 Sep 2014 11:44:15 +0000 (13:44 +0200)
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
addons/account_voucher/voucher_sales_purchase_view.xml

index 4b19ae6..25046a6 100644 (file)
@@ -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.
index 2dd5383..20ac768 100644 (file)
 
                     <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}" />