diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml
index 9985e134fb0..7962ce29bbf 100644
--- a/addons/account/account_invoice_view.xml
+++ b/addons/account/account_invoice_view.xml
@@ -198,7 +198,7 @@
-
+
@@ -289,7 +289,7 @@
-
+
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index 446fea4d0df..0227b37dd3b 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -419,7 +419,7 @@ class account_invoice(osv.osv):
return result
def onchange_currency_id(self, cr, uid, ids, curr_id, company_id):
- if curr_id:
+ if curr_id and company_id:
currency = self.pool.get('res.currency').browse(cr, uid, curr_id)
if currency.company_id.id != company_id:
raise osv.except_osv(_('Configration Error !'),
@@ -451,7 +451,7 @@ class account_invoice(osv.osv):
def onchange_partner_bank(self, cursor, user, ids, partner_bank_id):
return {'value': {}}
- def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line):
+ def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id):
val={}
dom={}
if company_id and part_id and type:
@@ -504,6 +504,21 @@ class account_invoice(osv.osv):
else:
journal_ids=self.pool.get('account.journal').search(cr,uid,[])
dom={'journal_id': [('id','in',journal_ids)]}
+
+ if currency_id and company_id:
+ currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
+ if 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.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