From 3da9e717110dcbb07c5ae4c4aa1d0a80e63350f0 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 1 Feb 2012 15:16:33 +0100 Subject: [PATCH] [FIX] account, invoice: removed the default value of currency_id field, as it should be given by the onchange of journal_id (which has a default value) bzr revid: qdp-launchpad@openerp.com-20120201141633-mclcw5n7v9c5789h --- addons/account/account_invoice.py | 23 ++--------------------- addons/account/account_invoice_view.xml | 2 +- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index edab8f90b3f..f83de4d9bf4 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -57,12 +57,6 @@ class account_invoice(osv.osv): limit=1) return res and res[0] or False - def _get_currency(self, cr, uid, context=None): - user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid], context=context)[0] - if user.company_id: - return user.company_id.currency_id.id - return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0] - 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') @@ -279,7 +273,6 @@ 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, @@ -464,10 +457,10 @@ class account_invoice(osv.osv): result['value'].update(to_update['value']) return result - def onchange_journal_id(self, cr, uid, ids, journal_id=False): + def onchange_journal_id(self, cr, uid, ids, journal_id=False, context=None): result = {} if journal_id: - journal = self.pool.get('account.journal').browse(cr, uid, journal_id) + journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context) currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id result = {'value': { 'currency_id': currency_id, @@ -572,18 +565,6 @@ class account_invoice(osv.osv): else: journal_ids = obj_journal.search(cr, uid, []) - if currency_id and company_id: - currency = self.pool.get('res.currency').browse(cr, uid, currency_id) - if currency.company_id and currency.company_id.id != company_id: - val['currency_id'] = False - else: - val['currency_id'] = currency.id - if company_id: - company = self.pool.get('res.company').browse(cr, uid, company_id) - if company.currency_id.company_id and company.currency_id.company_id.id != company_id: - val['currency_id'] = False - else: - val['currency_id'] = company.currency_id.id return {'value': val, 'domain': dom} # go from canceled state to draft state diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 986f21c27fa..12a34975dd6 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -256,7 +256,7 @@
- +