From 1928854809289d4c5a886ba02708e5de7df7ddf0 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 1 Feb 2012 17:06:48 +0100 Subject: [PATCH] [FIX] account: partial revert of commit 6465. Put back the default value on currency field but changed its implementation in order to have it computed thanks to the default journal bzr revid: qdp-launchpad@openerp.com-20120201160648-kei7wp4radcws0p9 --- addons/account/account_invoice.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index f83de4d9bf4..f2e3e35e047 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -57,6 +57,14 @@ class account_invoice(osv.osv): limit=1) return res and res[0] or False + def _get_currency(self, cr, uid, context=None): + res = False + journal_id = self._get_journal(cr, uid, context=context) + if journal_id: + journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) + res = journal.currency and journal.currency.id or journal.company_id.currency_id.id + return res + def _get_journal_analytic(self, cr, uid, type_inv, context=None): type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} tt = type2journal.get(type_inv, 'sale') @@ -273,6 +281,7 @@ class account_invoice(osv.osv): 'type': _get_type, 'state': 'draft', 'journal_id': _get_journal, + 'currency_id': _get_currency, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c), 'reference_type': 'none', 'check_total': 0.0,