From 7b51194e4e6de18c6ca781f20fb79f76ce2b14ee Mon Sep 17 00:00:00 2001 From: vra Date: Fri, 17 Sep 2010 11:40:44 +0530 Subject: [PATCH] [ADD] account: added onchange on invoice journal field to set the journal currency in invoice currency field otherwise company currency. bzr revid: vra@tinyerp.com-20100917061044-89lz92j7flcf53ta --- addons/account/account_invoice_view.xml | 4 ++-- addons/account/invoice.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 81391e796b9..4d0a73cb4d3 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -150,7 +150,7 @@
- + @@ -260,7 +260,7 @@ - + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 44a57c2e11d..0c0941c715a 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -452,6 +452,24 @@ class account_invoice(osv.osv): _('Can not select currency that is not related to current company.\nPlease select accordingly !.')) return {} + def onchange_journal_id(self, cr, uid, ids, journal_id, company_id): + result = {} + if journal_id and company_id: + company = self.pool.get('res.company').browse(cr, uid, company_id) + journal_id = self.pool.get('account.journal').browse(cr, uid, journal_id) + if journal_id.currency: + result = {'value': { + 'currency_id': journal_id.currency.id + } + } + else: + result = {'value': { + 'currency_id': company.currency_id.id + } + } + + return result + def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice): if not payment_term_id: return {}