diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml
index 2c91c8c53c2..d8270553cef 100644
--- a/addons/account/account_wizard.xml
+++ b/addons/account/account_wizard.xml
@@ -114,6 +114,7 @@
-
+
+
diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py
index 5e0e39bf8f7..d207c3d5c27 100644
--- a/addons/account/wizard/__init__.py
+++ b/addons/account/wizard/__init__.py
@@ -59,6 +59,7 @@ import wizard_statement_from_invoice
import wizard_print_journal
import wizard_central_journal
import wizard_general_journal
+import wizard_change_currency
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/wizard_change_currency.py b/addons/account/wizard/wizard_change_currency.py
new file mode 100644
index 00000000000..c2c0ffd1478
--- /dev/null
+++ b/addons/account/wizard/wizard_change_currency.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+import wizard
+import pooler
+
+class wizard_change_currency(wizard.interface):
+ '''
+ OpenERP Wizard
+ '''
+ form = '''
+ '''
+
+ message = '''
+ '''
+
+ fields = {
+ 'currency_id': {'string': 'New Currency', 'type': 'many2one', 'relation': 'res.currency', 'required':True},
+ }
+
+ def _get_defaults(self, cr, user, data, context):
+ #TODO : initlize required data
+
+ return data['form']
+
+ def _change_currency(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+
+ inv_obj = pool.get('account.invoice')
+ inv_line_obj = pool.get('account.invoice.line')
+ curr_obj = pool.get('res.currency')
+
+ invoice_ids = data['ids']
+ new_currency = data['form']['currency_id']
+
+ for invoice in inv_obj.browse(cr, uid, invoice_ids, context=context):
+ if invoice.currency_id.id == new_currency:
+ continue
+
+ for line in invoice.invoice_line:
+ rate = curr_obj.browse(cr, uid, new_currency).rate
+ new_price = 0
+ if invoice.company_id.currency_id.id == invoice.currency_id.id:
+ new_price = line.price_unit * rate
+
+ if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id == new_currency:
+ old_rate = invoice.currency_id.rate
+ new_price = line.price_unit / old_rate
+
+ if invoice.company_id.currency_id.id != invoice.currency_id.id and invoice.company_id.currency_id.id != new_currency:
+ old_rate = invoice.currency_id.rate
+ new_price = (line.price_unit / old_rate ) * rate
+
+ inv_line_obj.write(cr, uid, [line.id], {'price_unit':new_price})
+ inv_obj.write(cr, uid, [invoice.id], {'currency_id':new_currency})
+ return {}
+
+ def _check_what_next(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ inv_obj = pool.get('account.invoice')
+ if inv_obj.browse(cr, uid, data['id']).state != 'draft':
+ return 'message'
+
+ return 'change'
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type': 'choice', 'next_state': _check_what_next},
+ },
+ 'change': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch': form, 'fields': fields, 'state': (('end', 'Cancel'), ('next', 'Change Currency'))},
+ },
+ 'next': {
+ 'actions': [_change_currency],
+ 'result': {'type': 'state', 'state': 'end'},
+ },
+ 'message': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch': message, 'fields': {}, 'state': [('end', 'Ok')]},
+ },
+ }
+wizard_change_currency('account.invoice.currency_change')