← Back to team overview

account-payment-team team mailing list archive

lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 into lp:account-payment/7.0

 

Lorenzo Battistini - Agile BG has proposed merging lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 into lp:account-payment/7.0.

Requested reviews:
  Account Payment (account-payment-team)

For more details, see:
https://code.launchpad.net/~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7/+merge/165622
-- 
https://code.launchpad.net/~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7/+merge/165622
Your team Account Payment is requested to review the proposed merge of lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 into lp:account-payment/7.0.
=== added directory 'account_voucher_supplier_invoice_number'
=== added file 'account_voucher_supplier_invoice_number/AUTHORS.txt'
--- account_voucher_supplier_invoice_number/AUTHORS.txt	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/AUTHORS.txt	2013-05-24 13:58:47 +0000
@@ -0,0 +1,1 @@
+Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>

=== added file 'account_voucher_supplier_invoice_number/__init__.py'
--- account_voucher_supplier_invoice_number/__init__.py	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/__init__.py	2013-05-24 13:58:47 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import voucher

=== added file 'account_voucher_supplier_invoice_number/__openerp__.py'
--- account_voucher_supplier_invoice_number/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/__openerp__.py	2013-05-24 13:58:47 +0000
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': "Supplier invoice number in payment vouchers",
+    'version': '0.1',
+    'category': 'Accounting & Finance',
+    'description': """
+This module adds the supplier invoice number to (Supplier Payment) voucher lines. So that it's more easy to find the right invoice we are going to pay.
+""",
+    'author': 'Agile Business Group',
+    'website': 'http://www.agilebg.com',
+    'license': 'AGPL-3',
+    "depends" : ['account_voucher'],
+    "data" : [
+        'voucher_view.xml',
+        ],
+    'test' : [
+        'test/case5_suppl_usd_usd.yml',
+        'test/account_voucher.yml',
+        'test/sales_receipt.yml',
+        'test/sales_payment.yml',
+        'test/account_voucher_report.yml',
+        'test/case1_usd_usd.yml',
+        'test/case1_usd_usd_payment_rate.yml',
+        'test/case2_usd_eur_debtor_in_eur.yml',
+        'test/case2_usd_eur_debtor_in_usd.yml',
+        'test/case3_eur_eur.yml',
+        'test/case4_cad_chf.yml',
+        'test/case_eur_usd.yml',
+    ],
+    "demo" : [],
+    "active": False,
+    "installable": True
+}

=== added directory 'account_voucher_supplier_invoice_number/test'
=== added file 'account_voucher_supplier_invoice_number/test/account_voucher.yml'
--- account_voucher_supplier_invoice_number/test/account_voucher.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/account_voucher.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,86 @@
+-
+  In order to check account voucher module in OpenERP I create a customer voucher
+-
+  !record {model: account.voucher, id: account_voucher_voucherforaxelor0, view: account_voucher.view_sale_receipt_form}:
+    type: sale
+    account_id: account.cash
+    amount: 1000.0
+    company_id: base.main_company
+    journal_id: account.sales_journal
+    name: Voucher for Axelor
+    narration: Basic Pc
+    line_cr_ids:
+      - account_id: account.a_recv
+        amount: 1000.0
+        name: Voucher for Axelor
+    partner_id: base.res_partner_12
+    period_id: account.period_6
+    reference: none
+
+-
+  I check that Initially customer voucher is in the "Draft" state
+-
+  !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
+    - state == 'draft'
+-
+  I compute the voucher to calculate the taxes by clicking Compute button
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0}
+
+-
+  I create voucher by clicking on Create button
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0}
+-
+  I clicked on Validate Button
+-
+  !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
+    - state == 'posted'
+
+-
+  I check that Moves get created for this voucher
+-
+  !python {model: account.voucher}: |
+    acc_id=self.browse(cr, uid, ref("account_voucher_voucherforaxelor0"))
+    assert(acc_id.move_id)
+
+
+-
+  Now I create a Vendor Voucher
+-
+  !record {model: account.voucher, id: account_voucher_voucheraxelor0, view: account_voucher.view_voucher_filter_vendor}:
+    type: purchase
+    account_id: account.cash
+    amount: 1000.0
+    company_id: base.main_company
+    journal_id: account.bank_journal
+    name: Voucher Axelor
+    narration: PC Assemble SC234
+    line_dr_ids:
+      - account_id: account.cash
+        amount: 1000.0
+        name: Voucher Axelor
+    partner_id: base.res_partner_12
+    period_id: account.period_6
+    reference: none
+
+-
+  I check that Initially vendor voucher is in the "Draft" state
+-
+  !assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
+    - state == 'draft'
+-
+  I create voucher by clicking on Create button
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucheraxelor0}
+-
+  I check that the voucher state is "posted"
+-
+  !assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
+    - state == 'posted'
+-
+  I check that moves get created for this voucher
+-
+  !python {model: account.voucher}: |
+    acc_id=self.browse(cr, uid, ref("account_voucher_voucheraxelor0"))
+    assert(acc_id.move_id)

=== added file 'account_voucher_supplier_invoice_number/test/account_voucher_report.yml'
--- account_voucher_supplier_invoice_number/test/account_voucher_report.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/account_voucher_report.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,25 @@
+-
+  Demo for Account Voucher
+-
+  !record {model: account.voucher, id: account_voucher_voucheraxelor0again, view: account_voucher.view_sale_receipt_form}:
+    type: sale
+    account_id: account.cash
+    company_id: base.main_company
+    journal_id: account.bank_journal
+    name: Voucher Axelor
+    narration: PC Assemble SC234
+    amount: 1000.0
+    line_ids:
+      - account_id: account.cash
+        amount: 1000.0
+        name: Voucher Axelor
+    period_id: account.period_6
+
+-
+  In order to test the PDF reports defined on a account_voucher, we will print account voucher Report
+-
+  !python {model: account.voucher}: |
+    import netsvc, tools, os
+    (data, format) = netsvc.LocalService('report.voucher.cash_receipt.drcr').create(cr, uid, [ref("account_voucher_voucheraxelor0again")], {}, {})
+    if tools.config['test_report_directory']:
+        file(os.path.join(tools.config['test_report_directory'], 'account_voucher-report.'+format), 'wb+').write(data)

=== added file 'account_voucher_supplier_invoice_number/test/case1_usd_usd.yml'
--- account_voucher_supplier_invoice_number/test/case1_usd_usd.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case1_usd_usd.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,356 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in USD and make 2 Payments in USD based on the currency rating on that particular date
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I create currency USD in OpenERP for January of 1.333333 Rate
+-
+  !python {model: res.currency.rate}: |
+    from datetime import datetime
+    curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])[0]
+    date = '%s-01-01' %(datetime.now().year)
+    ids = self.search(cr, uid, [('currency_id','=',curr_id), ('name', '=', date)])
+    self.write(cr, uid, ids, {'rate': 1.333333})
+-
+  I create currency USD in OpenERP for February of 1.250000 Rate
+-
+  !record {model: res.currency.rate, id: feb_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-02-01' %(datetime.now().year)"
+    rate: 1.250000
+
+-
+  I create currency USD in OpenERP for March of 1.111111 Rate
+-
+  !record {model: res.currency.rate, id: mar_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 1.111111
+
+-
+  I create currency USD in OpenERP for April of 1.052632 Rate
+-
+  !record {model: res.currency.rate, id: apr_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-04-01' %(datetime.now().year)"
+    rate: 1.052632
+
+-
+  I create a cash account with currency USD
+-
+  !record {model: account.account, id: account_cash_usd_id}:
+    currency_id: base.USD
+    name: "cash account in usd"
+    code: "Xcash usd"
+    type: 'liquidity'
+    user_type: "account.data_account_type_cash"
+
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_usd_id
+    default_credit_account_id: account_cash_usd_id
+    currency: base.USD
+    company_id: base.main_company
+
+-
+  I create the first invoice on 1st January  for 200 USD
+-
+  !record {model: account.invoice, id: account_invoice_jan}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_jan}
+-
+  I check that first invoice move is correct for debtor account (debit - credit == 150.0)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account"
+-
+  I create the second invoice on 1st February for 100 USD
+-
+  !record {model: account.invoice, id: account_invoice_feb}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_2
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 100.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_feb}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == 80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account"
+
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  On the first March, I create the first voucher of payment with values 240 USD, journal USD, 
+-
+  !record {model: account.voucher, id: account_voucher_1_case1, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 240.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    name: 'First payment: Case 1 USD/USD'
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+
+-
+  I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 200.00:
+            data += [(item.id, 180.0)]
+        else:
+            data += [(item.id, 70.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -10.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my first voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with -180 and -70 as amount_currency columns and that their credit columns are respectively 162 and 63
+-
+  I check that my write-off is correct. 9 debit and 10 amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 1 USD/USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -180.00:
+            assert move_line.credit == 162.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == -70.00:
+            assert move_line.credit == 63.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == 10.00:
+            assert move_line.debit == 9.00, "Writeoff amount is wrong."
+        elif move_line.amount_currency == 240.00:
+            assert move_line.debit == 216.00, "Bank entry is wrong."
+        else:
+            assert False, "Unrecognized journal entry"
+-
+  I check the residual amount of Invoice1, should be 20 in amount_currency
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 20.0) , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 30.0) , "Residual amount is not correct for first Invoice"
+-
+  On the first April, I create the second voucher of payment with values 45 USD, journal USD, 
+-
+  !record {model: account.voucher, id: account_voucher_2_case1, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 45.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    name: 'Second payment: Case 1'
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-04-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+-
+  I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_2_case1'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 20.00:
+            data += [(item.id, 20.0)]
+        else:
+            data += [(item.id, 30.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -5.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == -5.0), "Writeoff amount is not -5.0"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my second voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with -20 and -30 as amount_currency columns and their credit columns are respectively 19 and 28.5
+-
+  I check that my currency rate difference is correct. 8.5 in credit with no amount_currency
+-
+  I  check that the total reconcilation created entries as expected
+-
+  I check that my writeoff is correct. 4.75 debit and 5 amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 1'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    reconcile_a = reconcile_b = False
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -20.00:
+            assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
+            reconcile_b = move_line.reconcile_id.id
+        elif move_line.amount_currency == -30.00:
+            assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
+            reconcile_a = move_line.reconcile_id.id
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -20.00:
+            assert move_line.credit == 19.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == -30.00:
+            assert move_line.credit == 28.50, "Debtor account has wrong entry."
+        elif move_line.amount_currency == 5.00:
+            assert move_line.debit == 4.75, "Writeoff amount is wrong."
+        elif move_line.debit == 11.5 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_a, "Exchange difference entry for the invoice of 100$ is wrong"
+        elif move_line.credit == 11.5:
+            assert move_line.amount_currency == 0.0
+        elif move_line.debit == 31.0 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.0 and move_line.reconcile_id.id == reconcile_b, "Exchange difference entry for the invoice of 200$ is wrong"
+        elif move_line.credit == 31.0:
+            assert move_line.amount_currency == 0.0
+        elif move_line.amount_currency == 45.00:
+            assert move_line.debit == 42.75, "Bank entry is wrong."
+        else:
+            assert False, "Unrecognized journal entry"
+-
+  I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_jan"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amuont of Invoice2, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_feb"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case1_usd_usd_payment_rate.yml'
--- account_voucher_supplier_invoice_number/test/case1_usd_usd_payment_rate.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case1_usd_usd_payment_rate.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,249 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in USD and make 1 Payment in USD based on the currency rating given by the bank which is slightly different that the one encoded in OpenERP
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I create currency USD in OpenERP for January of 1.333333 Rate
+-
+  !python {model: res.currency.rate}: |
+    from datetime import datetime
+    curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])[0]
+    date = '%s-01-01' %(datetime.now().year)
+    ids = self.search(cr, uid, [('currency_id','=',curr_id), ('name', '=', date)])
+    self.write(cr, uid, ids, {'rate': 1.333333})
+-
+  I create currency USD in OpenERP for February of 1.250000 Rate
+-
+  !record {model: res.currency.rate, id: feb_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-02-01' %(datetime.now().year)"
+    rate: 1.250000
+
+-
+  I create currency USD in OpenERP for March of 1.111111 Rate
+-
+  !record {model: res.currency.rate, id: mar_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 1.111111
+
+-
+  I create currency USD in OpenERP for April of 1.052632 Rate
+-
+  !record {model: res.currency.rate, id: apr_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-04-01' %(datetime.now().year)"
+    rate: 1.052632
+
+-
+  I create a cash account with currency USD
+-
+  !record {model: account.account, id: account_cash_usd_id}:
+    currency_id: base.USD
+    name: "cash account in usd"
+    code: "Xcash usd"
+    type: 'liquidity'
+    user_type: "account.data_account_type_cash"
+
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_usd_id
+    default_credit_account_id: account_cash_usd_id
+    currency: base.USD
+    company_id: base.main_company
+
+-
+  I create a new partner Kate Mc Kay
+-
+  !record {model: res.partner, id: res_partner_mc_kay}:
+    name: "Mc Kay Kate"
+    property_account_receivable: account.a_recv
+    property_account_payable: account.a_pay
+-
+  I create the first invoice on 1st January  for 200 USD
+-
+  !record {model: account.invoice, id: account_invoice_jan_payment_rate}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: res_partner_mc_kay
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_jan_payment_rate}
+-
+  I check that first invoice move is correct for debtor account (debit - credit == 150.0)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 150.0), "Invoice move is not correct for debtors account"
+-
+  I create the second invoice on 1st February for 100 USD
+-
+  !record {model: account.invoice, id: account_invoice_feb_payment_rate}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_2
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 100.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: res_partner_mc_kay
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_feb_payment_rate}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == 80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 80), "Invoice move is not correct for debtors account"
+
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  On the first March, I create the first voucher of payment with values 240 USD, journal USD, and specifying that $1 = 0.8€
+-
+  !record {model: account.voucher, id: account_voucher_1_case1_payment_rate, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 240.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    name: 'Payment: Case 1 USD/USD payment rate'
+    partner_id: res_partner_mc_kay
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    payment_rate: 0.8
+    payment_rate_currency_id: base.EUR
+
+-
+  I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case1_payment_rate'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 200.00:
+            data += [(item.id, 180.0)]
+        else:
+            data += [(item.id, 70.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -10.0
+-
+  !python {model: account.voucher}: |
+    voucher = ref('account_voucher_1_case1_payment_rate') 
+    voucher_id = self.browse(cr, uid, voucher)
+    assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', ref('account_voucher_1_case1_payment_rate'), 'proforma_voucher', cr)
+-
+  I check that the move of my first voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = ref('account_voucher_1_case1_payment_rate') 
+    voucher_id = self.browse(cr, uid, voucher)
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with -180 and -70 as amount_currency columns and that their credit columns are respectively 144 and 56
+-
+  I check that my write-off is correct. 8 debit and 10 amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = ref('account_voucher_1_case1_payment_rate') 
+    voucher_id = self.browse(cr, uid, voucher)
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -180.00:
+            assert move_line.credit == 144.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == -70.00:
+            assert move_line.credit == 56.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == 10.00:
+            assert move_line.debit == 8.00, "Writeoff amount is wrong: Got a debit of %s (expected 8,00€)" % (move_line.debit)
+        elif move_line.amount_currency == 240.00:
+            assert move_line.debit == 192.00, "Bank entry is wrong."
+        else:
+            assert False, "Unrecognized journal entry"
+-
+  I check the residual amount of Invoice1, should be 20 in amount_currency and 6 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_jan_payment_rate"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual == 6.0) , "Residual amount is not correct for first Invoice"
+    assert (move_line.amount_residual_currency == 20.0) , "Residual amount in currency is not correct for first Invoice"
+-
+  I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_feb_payment_rate"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual == 24.0) , "Residual amount is not correct for second Invoice"
+    assert (move_line.amount_residual_currency == 30.0) , "Residual amount in currency is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case2_suppl_usd_eur.yml'
--- account_voucher_supplier_invoice_number/test/case2_suppl_usd_eur.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case2_suppl_usd_eur.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,320 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I create a bank journal with EUR as currency
+-
+  !record {model: account.journal, id: bank_journal_EUR}:
+    name: Bank Journal(EUR)
+    code: BEUR
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    currency: base.EUR
+    company_id: base.main_company
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    currency: base.USD
+    company_id: base.main_company
+-
+  I create the first invoice on 1st January for 200 USD
+-
+  !record {model: account.invoice, id: account_first_invoice_jan_suppl}:
+    account_id: account.a_pay
+    type : in_invoice
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_expense
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+    check_total : 200
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_suppl}
+-
+  I check that first invoice move is correct for debtor account(debit - credit == -150)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == -150.00), "Invoice move is incorrect for debtors account"
+-
+  I create the second invoice on 1st February for 100 USD
+-
+  !record {model: account.invoice, id: account_second_invoice_feb_suppl}:
+    account_id: account.a_pay
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_2
+    type : in_invoice
+    invoice_line:
+      - account_id: account.a_expense
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 100.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+    check_total : 100.0
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_suppl}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == -80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == -80), "Invoice move is incorrect for debtors account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'payment'
+-
+  I create the first voucher of payment with values 240 EUR, journal EUR
+-
+  !record {model: account.voucher, id: account_voucher_1_case2_suppl, view: account_voucher.view_vendor_payment_form}:
+    account_id: account.cash
+    amount: 240.0
+    company_id: base.main_company
+    journal_id: bank_journal_EUR
+    name: 'First payment: Case 2 SUPPL USD/EUR',
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+
+-
+  I fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2_suppl'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 200.00:
+            data += [(item.id, 180.0)]
+        else:
+            data += [(item.id, 70.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -15.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == -15.0), "Writeoff amount is not -15.0"
+-
+  I check that currency rate difference is 34.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.currency_rate_difference == 34.0), "Currency rate difference is not 34.0"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my creditor account is correct
+-
+  I check that the creditor account has 2 new lines with 180 and 70 in amount_currency columns and their debit columns are respectively 135 and 56 and currency is USD($).
+-
+  I check that my currency rate difference is correct. -34 in credit with no amount_currency
+-
+  I check that my writeoff is correct. -15 in credit with no amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == 180.00:
+            assert move_line.debit == 135.00, "Creditor account has wrong entry."
+        elif move_line.amount_currency == 70.00:
+            assert move_line.debit == 56.00, "Debtor account has wrong entry."
+        elif move_line.debit == 34.00:
+            assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
+        elif move_line.debit == 15.00:
+            assert move_line.amount_currency == 0.00, "Writeoff amount is wrong."
+-
+  I check the residual amount of Invoice1, should be 20 in residual currency and 15 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 20.0 and move_line.amount_residual == 15) , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amuont of Invoice2, should be 30 in residual currency and 24 in amount_residual
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 30 and move_line.amount_residual == 24) , "Residual amount is not correct for second Invoice"
+-
+  I create the second voucher of payment with values 45 USD, journal USD, 
+-
+  !record {model: account.voucher, id: account_voucher_2_case2_suppl, view: account_voucher.view_vendor_payment_form}:
+    account_id: account.cash
+    amount: 45.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-04-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'Second payment: Case 2 SUPPL USD/EUR'
+
+-
+  I fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2_suppl'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 20.00:
+            data += [(item.id, 20.0)]
+        else:
+            data += [(item.id, 30.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -5.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == 5.0), "Writeoff amount is not 5.0"
+-
+  I check that currency rate difference is 8.50
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.currency_rate_difference == 8.50), "Currency rate difference is not 8.50"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that my voucher state is posted
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert voucher_id.state == 'posted', "Voucher state is not posted"
+-
+  I check that my creditor account is correct
+-
+  I check that the creditor account has 2 new lines with 20 and 30 in amount_currency columns and their debit columns are respectively 15 and 24 and currency is USD($).
+-
+  I check that my currency rate difference is correct. 8.50 in debit with no amount_currency
+-
+  I check that my writeoff is correct. 4.75 in credit and 5 in amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == 20.00:
+            assert move_line.debit == 15.00, "Debtor account has wrong entry."
+        elif move_line.amount_currency == 30.00:
+            assert move_line.debit == 24.00, "Debtor account has wrong entry."
+        elif move_line.debit == 8.50:
+            assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
+        elif move_line.amount_currency == -5.00:
+            assert move_line.credit == 4.75, "Writeoff amount is wrong."
+-
+  I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_suppl"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+-    
+  I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_suppl"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_eur.yml'
--- account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_eur.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_eur.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,318 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I modify the debtor account in order to make sure there is no currency_id linked
+-
+  !python {model: account.account}: |
+    from datetime import datetime
+    ids = self.search(cr, uid, [('name', 'ilike', 'debtor')])
+    self.write(cr, uid, ids, {'currency_id': False})
+-
+  I create currency USD in OpenERP for January of 1.333333 Rate
+-
+  !python {model: res.currency.rate}: |
+    from datetime import datetime
+    curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])[0]
+    date = '%s-01-01' %(datetime.now().year)
+    ids = self.search(cr, uid, [('currency_id', '=', curr_id), ('name', '=', date)])
+    self.write(cr, uid, ids, {'rate': 1.333333})
+-
+  I create currency USD in OpenERP for February of 1.250000 Rate
+-
+  !record {model: res.currency.rate, id: feb_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-02-01' %(datetime.now().year)"
+    rate: 1.250000
+-
+  I create currency USD in OpenERP for March of 1.111111 Rate
+-
+  !record {model: res.currency.rate, id: mar_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 1.111111
+-
+  I create currency USD in OpenERP for April of 1.052632 Rate
+-
+  !record {model: res.currency.rate, id: apr_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-04-01' %(datetime.now().year)"
+    rate: 1.052632
+-
+  I create a bank journal with EUR as currency
+-
+  !record {model: account.journal, id: bank_journal_EUR}:
+    name: Bank Journal(EUR)
+    code: BEUR
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    company_id: base.main_company
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_usd_id
+    default_credit_account_id: account_cash_usd_id
+    currency: base.USD
+    company_id: base.main_company
+-
+  I create the first invoice on 1st January for 200 USD
+-
+  !record {model: account.invoice, id: account_first_invoice_jan}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan}
+-
+  I check that first invoice move is correct for debtor account(debit - credit == 150)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+-
+  I create the second invoice on 1st February for 100 USD
+-
+  !record {model: account.invoice, id: account_second_invoice_feb}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_2
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 100.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == 80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  I create the first voucher of payment with values 200 EUR, journal EUR 
+-
+  !record {model: account.voucher, id: account_voucher_1_case2a, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 200.0
+    company_id: base.main_company
+    journal_id: bank_journal_EUR
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'First payment: Case 2 USD/EUR DR EUR'
+
+-
+  I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2a'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 150.00:
+            data += [(item.id, 130.0)]
+        else:
+            data += [(item.id, 70.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice. Got %s USD (%s EUR)" %(move_line.amount_residual_currency, move_line.amount_residual)
+-
+  I check the residual amuont of Invoice2, should be 22.22 in residual currency and 10 in amount_residual
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice"
+-
+  I create the second voucher of payment with values 80 USD, journal USD
+-
+  !record {model: account.voucher, id: account_voucher_2_case2a, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 80
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-04-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'Second payment: Case 2 SUPPL USD/EUR DR EUR'
+
+-
+  and I fully reconcile the 2 previous invoices
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2a'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 55.56:
+            data += [(item.id, 55.56)]
+        else:
+            data += [(item.id, 22.22)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is 2.22
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that my voucher state is posted
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert voucher_id.state == 'posted', "Voucher state is not posted"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with -55.56 and -22.22 in amount_currency columns and their credit columns are respectively 52.78 and 21.11 and currency is USD($).
+-
+  I check that my currency rate difference is correct.
+-
+  I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR EUR'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    reconcile_a = reconcile_b = False
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -22.22:
+            assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
+            reconcile_b = move_line.reconcile_id.id
+        elif move_line.amount_currency == -55.56:
+            assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
+            reconcile_a = move_line.reconcile_id.id
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -55.56:
+            assert move_line.credit == 52.78, "Debtor account has wrong entry."
+        elif move_line.amount_currency == -22.22:
+            assert move_line.credit == 21.11, "Debtor account has wrong entry."
+        elif move_line.credit == 11.11 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
+        elif move_line.credit == 32.78 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
+        elif move_line.amount_currency == 2.22:
+            assert move_line.credit == 2.11, "Writeoff amount is wrong."
+-
+  I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+-    
+  I check the residual amuont of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_usd.yml'
--- account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_usd.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case2_usd_eur_debtor_in_usd.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,333 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in USD and make 2 Payments one in USD and another in EUR, based on the currency rating on that particular date
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I modify the debtor account in order to set the currency_id = USD
+-
+  !python {model: account.account}: |
+    from datetime import datetime
+    ids = self.search(cr, uid, [('name', 'ilike', 'debtor')])
+    self.write(cr, uid, ids, {'currency_id': ref('base.USD')})
+-
+  I create currency USD in OpenERP for January of 1.333333 Rate
+-
+  !python {model: res.currency.rate}: |
+    from datetime import datetime
+    curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])[0]
+    date = '%s-01-01' %(datetime.now().year)
+    ids = self.search(cr, uid, [('currency_id', '=', curr_id), ('name', '=', date)])
+    self.write(cr, uid, ids, {'rate': 1.333333})
+-
+  I create currency USD in OpenERP for February of 1.250000 Rate
+-
+  !record {model: res.currency.rate, id: feb_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-02-01' %(datetime.now().year)"
+    rate: 1.250000
+-
+  I create currency USD in OpenERP for March of 1.111111 Rate
+-
+  !record {model: res.currency.rate, id: mar_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 1.111111
+-
+  I create currency USD in OpenERP for April of 1.052632 Rate
+-
+  !record {model: res.currency.rate, id: apr_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-04-01' %(datetime.now().year)"
+    rate: 1.052632
+-
+  I create a bank journal with EUR as currency
+-
+  !record {model: account.journal, id: bank_journal_EUR}:
+    name: Bank Journal(EUR)
+    code: BEUR
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    company_id: base.main_company
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_usd_id
+    default_credit_account_id: account_cash_usd_id
+    currency: base.USD
+    company_id: base.main_company
+-
+  I create the first invoice on 1st January for 200 USD
+-
+  !record {model: account.invoice, id: account_first_invoice_jan_michal}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_michal}
+-
+  I check that first invoice move is correct for debtor account(debit - credit == 150)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+-
+  I create the second invoice on 1st February for 100 USD
+-
+  !record {model: account.invoice, id: account_second_invoice_feb_michal}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_2
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 100.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_michal}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == 80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 80), "Invoice move is incorrect for debtors account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  I create the first voucher of payment with values 200 EUR, journal EUR
+-
+  !record {model: account.voucher, id: account_voucher_1_case2b, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 200.0
+    company_id: base.main_company
+    journal_id: bank_journal_EUR
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'First payment: Case 2 USD/EUR DR USD'
+
+-
+  I fill amounts 130 for the invoice of 200$ and 70 for the invoice of 100$>
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case2b'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 150.00:
+            data += [(item.id, 130.0)]
+        else:
+            data += [(item.id, 70.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with 144.44 and 77.78 in amount_currency columns and their credit columns are 130 and 70
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 2 USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.credit == 70.0:
+            assert move_line.amount_currency == -77.78, "Wrong debtor entry"
+        if move_line.credit == 130.0:
+            assert move_line.amount_currency == -144.44, "Wrong debtor entry"
+-
+  I check the residual amount of Invoice1, should be 55.56 in residual currency and 20 in amount_residual
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 55.56 and move_line.amount_residual == 20) , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amount of Invoice2, should be 22.22 in residual currency and 10 in amount_residual
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 22.22 and move_line.amount_residual == 10) , "Residual amount is not correct for second Invoice"
+-
+  I create the second voucher of payment with values 80 USD, journal USD
+-
+  !record {model: account.voucher, id: account_voucher_2_case2b, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 80.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-04-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'Second payment: Case 2 SUPPL USD/EUR DR USD'
+
+-
+  and I fully reconcil the 2 previous invoices
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_2_case2b'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 55.56:
+            data += [(item.id, 55.56)]
+        else:
+            data += [(item.id, 22.22)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is 2.22
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (round(voucher_id.writeoff_amount, 2) == 2.22), "Writeoff amount is not 2.22$"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that my voucher state is posted
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert voucher_id.state == 'posted', "Voucher state is not posted"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with -55.56 and -22.22 in amount_currency columns and their credit columns are respectively 52.78 and 21.11 and currency is USD($).
+-
+  I check that my currency rate difference is correct.
+-
+  I check that my writeoff is correct. 2.11 in credit and 2.22 in amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 2 SUPPL USD/EUR DR USD'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    reconcile_a = reconcile_b = False
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -22.22:
+            assert move_line.reconcile_id.id, "The invoice of 200$ is not fully reconciled"
+            reconcile_b = move_line.reconcile_id.id
+        elif move_line.amount_currency == -55.56:
+            assert move_line.reconcile_id.id, "The invoice of 100$ is not fully reconciled"
+            reconcile_a = move_line.reconcile_id.id
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == -55.56:
+            assert move_line.credit == 52.78, "Debtor account has wrong entry."
+        elif move_line.amount_currency == -22.22:
+            assert move_line.credit == 21.11, "Debtor account has wrong entry."
+        elif move_line.credit == 11.11 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_b, "Incorrect Currency Difference."
+        elif move_line.credit == 32.78 and move_line.account_id.reconcile:
+            assert move_line.amount_currency == 0.00 and move_line.reconcile_id.id == reconcile_a, "Incorrect Currency Difference."
+        elif move_line.amount_currency == 2.22:
+            assert move_line.credit == 2.11, "Writeoff amount is wrong."
+-
+  I check the residual amount of invoice 1, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_michal"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amount of invoice 2, should be 0 in residual currency and 0 in amount_residual and paid
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_michal"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case3_eur_eur.yml'
--- account_voucher_supplier_invoice_number/test/case3_eur_eur.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case3_eur_eur.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,280 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create 2 Invoices in EUR and make 2 Payments in EUR based on the currency rating on that particular date.
+-
+  I create currency EUR in OpenERP for January of 1.000000 Rate
+-
+  !record {model: res.currency.rate, id: jan_eur}:
+    currency_id: base.EUR
+    name: !eval "'%s-01-01' %(datetime.now().year)"
+    rate: 1.000000
+-
+  I modify the debtor account in order to make sure there is no currency_id linked
+-
+  !python {model: account.account}: |
+    from datetime import datetime
+    ids = self.search(cr, uid, [('name', 'ilike', 'debtor')])
+    self.write(cr, uid, ids, {'currency_id': False})
+-
+  I create a bank journal with EUR as currency
+-
+  !record {model: account.journal, id: bank_journal_EUR}:
+    name: Bank Journal(EUR)
+    code: BEUR
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    company_id: base.main_company
+-
+  I create the first invoice on 1st January for 150 EUR
+-
+  !record {model: account.invoice, id: account_first_invoice_jan_eur}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.EUR
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 150.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_eur}
+-
+  I check that first invoice move is correct for debtor account(debit - credit == 150)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 150.00), "Invoice move is incorrect for debtors account"
+-
+  I create the second invoice on 1st February for 80 EUR
+-
+  !record {model: account.invoice, id: account_second_invoice_feb_eur}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.EUR
+    date_invoice: !eval "'%s-02-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 80.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_second_invoice_feb_eur}
+-
+  I check that second invoice move is correct for debtor account (debit - credit == 80)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 80.00), "Invoice move is incorrect for debtors account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  I create the first voucher of payment with values 120 EUR, journal EUR
+-
+  !record {model: account.voucher, id: account_voucher_1_case3, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 120.0
+    company_id: base.main_company
+    journal_id: bank_journal_EUR
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'First payment: Case 3'
+
+-
+  I fill amounts 100 for the invoice of 150€ and 20 for the invoice of 80€
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case3'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 150.00:
+            data += [(item.id, 100.0)]
+        else:
+            data += [(item.id, 20.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is 0.00
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my first voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 20 and 100 respectively
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.credit == 20.00:
+            assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+        elif move_line.credit == 100.00:
+            assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+-
+  I check the residual amount of Invoice1 is 50
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 50.0 and move_line.amount_residual == 50.0) , "Residual amount is not correct for first Invoice"
+-
+  I check the residual amuont of Invoice2 is 60
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 60.0 and move_line.amount_residual == 60.0) , "Residual amount is not correct for second Invoice"
+-
+  I create the second voucher of payment with values 120€, journal EUR, and check to let open the debtor overpaid amount
+-
+  !record {model: account.voucher, id: account_voucher_2_case3, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 120.0
+    company_id: base.main_company
+    journal_id: bank_journal_EUR
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-04-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'Second payment: Case 3'
+
+-
+  I fill amounts 50 for the invoice of 150€ and 70 for the invoice of 80€
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_2_case3'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 50.00:
+            data += [(item.id, 50.0)]
+        elif item.amount_unreconciled == 60.00:
+            data += [(item.id, 70.00)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is 0.00
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'),('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my second voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 2 new lines with 0.00 and 0.00 in amount_currency columns and their credit are 70 and 50
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'Second payment: Case 3'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.credit == 70.00:
+            assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+        elif move_line.credit == 50.00:
+            assert move_line.amount_currency == 0.00, "Debtor account has wrong entry."
+-
+  I check the residual amount of Invoice1 is 0
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_eur"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0 and move_line.amount_residual == 0) , "Residual amount is not correct for first Invoice"
+-    
+  I check the residual amuont of Invoice2 is -10
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_second_invoice_feb_eur"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == -10.0 and move_line.amount_residual == -10.0) , "Residual amount is not correct for second Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case4_cad_chf.yml'
--- account_voucher_supplier_invoice_number/test/case4_cad_chf.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case4_cad_chf.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,193 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP,
+  I create an invoice in CAD and make its Payment in CHF based on the currency rating on that particular date.
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I create currency CAD in OpenERP for January of 1.338800 Rate
+-
+  !record {model: res.currency.rate, id: jan_cad}:
+    currency_id: base.CAD
+    name: !eval "'%s-01-01' %(datetime.now().year)"
+    rate: 1.338800
+-
+  I create currency CAD in OpenERP for March of 2.000000 Rate
+-
+  !record {model: res.currency.rate, id: mar_cad}:
+    currency_id: base.CAD
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 2.000000
+-
+  I create currency CHF in OpenERP for January of 1.308600 Rate
+-
+  !record {model: res.currency.rate, id: jan_chf}:
+    currency_id: base.CHF
+    name: !eval "'%s-01-01' %(datetime.now().year)"
+    rate: 1.308600
+-
+  I create currency CHF in OpenERP for March of 1.250000 Rate
+-
+  !record {model: res.currency.rate, id: mar_chf}:
+    currency_id: base.CHF
+    name: !eval "'%s-03-01' %(datetime.now().year)"
+    rate: 1.25000
+-
+  I create a cash account with currency CHF
+-
+  !record {model: account.account, id: account_cash_chf_id}:
+    currency_id: base.CHF
+    name: "cash account in chf"
+    code: "Xcash chf"
+    type: 'liquidity'
+    user_type: "account.data_account_type_cash"
+
+-
+  I create a bank journal with CHF as currency
+-
+  !record {model: account.journal, id: bank_journal_CHF}:
+    name: Bank Journal(CHF)
+    code: BCHF
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_chf_id
+    default_credit_account_id: account_cash_chf_id
+    currency: base.CHF
+    company_id: base.main_company
+-
+  I create the first invoice on 1st January for 200 CAD
+-
+  !record {model: account.invoice, id: account_first_invoice_jan_cad}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.CAD
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 200.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_first_invoice_jan_cad}
+-
+  I check that first invoice move is correct for debtor account (debit - credit == 149.39)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == 149.39), "Invoice move is incorrect for debtors account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'receipt'
+-
+  I create the first voucher of payment with values 200 CHF, journal CHF
+-
+  !record {model: account.voucher, id: account_voucher_1_case4, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 200
+    company_id: base.main_company
+    journal_id: bank_journal_CHF
+    partner_id: base.res_partner_19
+    period_id: account.period_3
+    date: !eval time.strftime("%Y-03-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    name: 'First payment: Case 4'
+-
+  I completly pay the invoice of 200 CAD
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_1_case4'))
+    data = []
+    for item in voucher_id.line_cr_ids:
+        if item.amount_unreconciled == 186.74:
+            data += [(item.id, 186.74)]
+        else:
+            data += [(item.id, 0.0)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is 13.26
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    assert (round(voucher_id.writeoff_amount,2) == 13.26), "Writeoff amount is not 13.26 CHF"
+-
+  I confirm the voucher
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher[0], 'proforma_voucher', cr)
+-
+  I check that the move of my voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        assert move_line.state == 'valid', "Voucher move is not valid"
+    assert voucher_id.state == 'posted', "Voucher state is not posted"
+-
+  I check that my debtor account is correct
+-
+  I check that the debtor account has 1 new line with -298.78 as amount_currency columns and 149.39 of credit and currency is CAD.
+-
+  I check that my currency rate difference is correct. 0 in debit with 98.78 CAD as amount_currency
+-
+  I check that my writeoff is correct. 11.05 credit and -13.26 amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.search(cr, uid, [('name', '=', 'First payment: Case 4'), ('partner_id', '=', ref('base.res_partner_19'))])
+    voucher_id = self.browse(cr, uid, voucher[0])
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', voucher_id.move_id.id)])
+    for move_line in move_line_obj.browse(cr, uid, move_lines):
+        if move_line.amount_currency == 200:
+            assert move_line.debit == 160.00, "Bank account has wrong entry."
+        elif move_line.amount_currency == -298.78:
+            assert move_line.credit == 149.39, "Debtor account has wrong entry."
+        elif move_line.debit == 0.00 and move_line.credit == 0.00:
+            assert move_line.amount_currency == 98.78, "Incorrect Currency Difference, got %s as amount_currency (expected 98.78)." % (move_line.amount_currency)
+            assert move_line.currency_id.id == ref('base.CAD'), "Incorrect Currency Difference, got %s (expected 'CAD')" % (move_line.currency_id.name)
+        elif move_line.credit == 10.61:
+            assert move_line.amount_currency == -13.26, "Writeoff amount is wrong."
+        else:
+            assert False, "Wrong entry"
+-
+  I check the residual amount of Invoice1, should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_first_invoice_jan_cad"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for first Invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case5_suppl_usd_usd.yml'
--- account_voucher_supplier_invoice_number/test/case5_suppl_usd_usd.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case5_suppl_usd_usd.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,183 @@
+-
+  In order to check the Account_voucher module with multi-currency in OpenERP, 
+  I create a supplier invoices in USD and make the payment in USD but with another exchange rate and with a write-off
+-
+  I create a cash account with currency USD
+-
+  !record {model: account.account, id: account_cash_usd_id2}:
+    currency_id: base.USD
+    name: "cash account in usd"
+    code: "Xcash usd2"
+    type: 'liquidity'
+    user_type: "account.data_account_type_cash"
+
+-
+  I create currency USD in OpenERP for November of 1.8 Rate
+-
+  !record {model: res.currency.rate, id: nov_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-11-01' %(datetime.now().year)"
+    rate: 1.8
+-
+  I create currency USD in OpenERP for December of 1.5 Rate
+-
+  !record {model: res.currency.rate, id: dec_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-12-01' %(datetime.now().year)"
+    rate: 1.5
+-
+  I set the income and expense currency accounts on the main company
+-
+  !python {model: res.company}: |
+    from datetime import datetime
+    vals = {
+      'income_currency_exchange_account_id': ref('account.o_expense'),
+      'expense_currency_exchange_account_id': ref('account.o_expense')}
+    self.write(cr, uid, ref('base.main_company'), vals)
+-
+  I create a bank journal with EUR as currency
+-
+  !record {model: account.journal, id: bank_journal_EUR}:
+    name: Bank Journal(EUR)
+    code: BEUR
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account.cash
+    default_credit_account_id: account.cash
+    company_id: base.main_company
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD}:
+    name: Bank Journal(USD)
+    code: BUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_cash_usd_id2
+    default_credit_account_id: account_cash_usd_id2
+    currency: base.USD
+    company_id: base.main_company
+-
+  I set the context as would do the action in supplier invoice menuitem
+-
+  !context
+    'default_type': 'in_invoice'
+-
+  I create the invoice on 1st november for 1000 USD
+-
+  !record {model: account.invoice, id: account_supplier_invoice_november, view: account.invoice_supplier_form}:
+    account_id: account.a_pay
+    company_id: base.main_company
+    currency_id: base.USD
+    date_invoice: !eval "'%s-11-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_expense
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 1000.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+    reference_type: none
+    check_total : 1000
+-
+  I Validate invoice by clicking on Validate button
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_supplier_invoice_november}
+-
+  I check that first invoice move is correct for creditor account(debit - credit == -555.56)
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_supplier_invoice_november"))
+    assert invoice_id.move_id, "Move not created for open invoice"
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.debit - move_line.credit == -555.56), "Invoice move is incorrect for creditor account"
+    assert (move_line.amount_currency == -1000), "Amount currency is incorrect for creditor account"
+-
+  I set the context that will be used for the encoding of all the vouchers of this file
+-
+  !context
+    'type': 'payment'
+-
+  I create the voucher of payment with values $950, journal USD
+-
+  !record {model: account.voucher, id: account_voucher_case_5_supplier_flow, view: account_voucher.view_vendor_payment_form}:
+    account_id: account.cash
+    amount: 950.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD
+    name: 'Payment: Case Basic SUPPLIER USD/USD'
+    partner_id: base.res_partner_19
+    period_id: account.period_12
+    date: !eval time.strftime("%Y-12-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+    type: 'payment'
+-
+  I fill $1000 for the previously encoded invoice
+-
+  !python {model: account.voucher}: |
+    import netsvc, time
+    vals = {}
+    voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow'))
+    for item in voucher_id.line_dr_ids:
+        if item.amount_unreconciled == 1000.00:
+            self.pool.get('account.voucher.line').write(cr, uid, [item.id], {'amount': 1000})
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -50.0
+-
+  !assert {model: account.voucher, id: account_voucher_case_5_supplier_flow}:
+    - writeoff_amount == -50.0
+-
+  I confirm the voucher
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_case_5_supplier_flow}
+-
+  I check that the move of my voucher is valid and that it is posted
+-
+  !python {model: account.voucher}: |
+    voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow'))
+    assert voucher_id.state == 'posted', "Voucher state is not posted"
+    for move_line in voucher_id.move_id.line_id:
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my creditor account is correct
+-
+  I check that the bank entry is -$950 and 633.33€ as amount_currency and credit, respectively.
+-
+  I check that the creditor account has 1 new line with $1000 and 666.67€ as amount_currency and debit, respectively.
+-
+  I check that my currency rate difference is correct (111.11€ in debit/credit with no amount_currency)
+-
+  I check that my writeoff is correct. 33.34€ in credit with -$50 as amount currency
+-
+  !python {model: account.voucher}: |
+    voucher_id = self.browse(cr, uid, ref('account_voucher_case_5_supplier_flow'))
+    for move_line in voucher_id.move_id.line_id:
+        if move_line.amount_currency == -950.00:
+            assert move_line.credit == 633.33, "Wrong bank entry."
+        elif move_line.credit == 111.11 or move_line.debit == 111.11:
+            assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
+        elif move_line.credit == 33.34:
+            assert move_line.amount_currency == -50.0, "Writeoff amount is wrong."
+        elif move_line.debit == 666.67:
+            assert move_line.amount_currency == 1000.0, "Wrong supplier entry."
+        else:
+            assert False, "Wrong entry. Unrecognized account move line"
+-
+  I check the residual amount of invoice, it should be 0 in residual currency and 0 in amount_residual and paid
+-
+   !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_supplier_invoice_november"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for supplier invoice"

=== added file 'account_voucher_supplier_invoice_number/test/case_eur_usd.yml'
--- account_voucher_supplier_invoice_number/test/case_eur_usd.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/case_eur_usd.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,169 @@
+##YAML test on the account_voucher as depicted in this bug report: https://bugs.launchpad.net/openobject-addons/+bug/954155
+-
+  In order to check the payment with multi-currency in OpenERP, 
+  I create an invoice in EUR and make payment in USD based on the currency rating.
+-
+  I update the Currency USD in OpenERP for January with rate 1.200000
+-
+  !python {model: res.currency.rate}: |
+    from datetime import datetime
+    curr_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'USD')])[0]
+    date = '%s-01-01' %(datetime.now().year)
+    ids = self.search(cr, uid, [('currency_id','=',curr_id), ('name', '=', date)])
+    self.write(cr, uid, ids, {'rate': 1.200000})
+-
+  I update the Currency USD in OpenERP for February with rate 1.400000
+-
+  !record {model: res.currency.rate, id: feb_usd}:
+    currency_id: base.USD
+    name: !eval "'%s-02-01' %(datetime.now().year)"
+    rate: 1.400000
+-
+  I create a bank account with USD as currency
+-
+  !record {model: account.account, id: account_eur_usd_id}:
+    currency_id: base.USD
+    name: "Bank usd"
+    code: "BUSD"
+    type: 'liquidity'
+    user_type: account.data_account_type_asset
+-
+  I create a bank journal with USD as currency
+-
+  !record {model: account.journal, id: bank_journal_USD1}:
+    name: Bank Journal Test(USD)
+    code: BEUSD
+    type: bank
+    analytic_journal_id: account.sit
+    sequence_id: account.sequence_bank_journal
+    default_debit_account_id: account_eur_usd_id
+    default_credit_account_id: account_eur_usd_id
+    currency: base.USD
+    company_id: base.main_company
+-
+  On the first of January, I create an invoice of 1000€
+-
+  !record {model: account.invoice, id: account_invoice_eur_usd}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.EUR
+    date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
+    period_id: account.period_1
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 1000.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+-
+  I validate the invoice.
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_eur_usd}
+-
+  I check that invoice move is correct
+-
+  !python {model: account.invoice}: |
+    invoice = self.browse(cr, uid, ref("account_invoice_eur_usd"))
+    assert invoice.state == 'open', "invoice state is not open"
+    assert invoice.period_id, "Period is not created for open invoice"
+    assert invoice.move_id, "Move not created for open invoice"
+    assert invoice.move_id.state == 'posted', "Move state is not posted"
+    for move_line in invoice.move_id.line_id:
+        assert move_line.state == 'valid', "Move line state is not valid"
+-
+  I set the type receipt for this voucher
+-
+  !context
+    'type': 'receipt'
+-
+  On the first of February, I create the voucher of payment with values 1350 USD, journal USD,
+-
+  !record {model: account.voucher, id: account_voucher_eur_usd_case, view: account_voucher.view_vendor_receipt_form}:
+    account_id: account.cash
+    amount: 1350.0
+    company_id: base.main_company
+    journal_id: bank_journal_USD1
+    name: 'payment: Case EUR/USD'
+    partner_id: base.res_partner_19
+    period_id: account.period_5
+    date: !eval time.strftime("%Y-02-01")
+    payment_option: 'with_writeoff'
+    writeoff_acc_id: account.a_expense
+    comment: 'Write Off'
+-
+  I fill amount 1400 for the invoice of 1400$
+-
+  !python {model: account.voucher}: |
+    data = []
+    voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
+    for item in voucher.line_cr_ids:
+        if item.amount_unreconciled == 1400:
+            data += [(item.id, 1400)]
+    for line_id, amount in data:
+        self.pool.get('account.voucher.line').write(cr, uid, [line_id], {'amount': amount})
+    assert (voucher.state=='draft'), "Voucher is not in draft state"
+-
+  I check that writeoff amount computed is -50.0
+-
+  !python {model: account.voucher}: |
+    voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
+    assert (voucher.writeoff_amount == -50.0), "Writeoff amount is not -50.0"
+-
+  I confirm the voucher
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_eur_usd_case}
+-
+  I check that the voucher state is "Posted"
+-
+  !assert {model: account.voucher, id: account_voucher_eur_usd_case}:
+    - state == 'posted'
+-
+  I check that the move of voucher is valid
+-
+  !python {model: account.voucher}: |
+    voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
+    assert voucher.move_ids, "Move line is not created for this voucher"
+    assert (voucher.number == voucher.move_ids[0].move_id.name), "referance number is not created"
+    assert voucher.period_id, "period is not created"
+    for move_line in voucher.move_ids:
+        assert move_line.state == 'valid', "Voucher move is not valid"
+-
+  I check that my debtor account is correct
+-
+  I check that my currency rate difference is correct. 1000 in credit with no amount_currency
+-
+  I  check that the total reconcilation created entries as expected
+-
+  I check that my writeoff is correct. 35.71 debit and 50 amount_currency
+-
+  I check that my bank account is correct. 964.29 debit and 1350 amount_currency
+-
+  !python {model: account.voucher}: |
+    voucher = self.browse(cr, uid, ref('account_voucher_eur_usd_case'))
+    for move_line in voucher.move_ids:
+        if move_line.amount_currency == 1350:
+            assert move_line.debit == 964.29,"debtor account is not correct"
+        if move_line.amount_currency == 50:
+            assert move_line.debit == 35.71,"write off bank account is not correct"
+        if move_line.amount_currency == 0.0:
+            assert move_line.credit == 1000,"total reconcile is not correct of invoice"
+-
+  I check that the move of payment in invoice is valid
+-
+  !python {model: account.invoice}: |
+    invoice = self.browse(cr, uid, ref("account_invoice_eur_usd"))
+    for payment_line in invoice.payment_ids:
+        assert payment_line.state == 'valid', "payment move line state is not valid"
+-
+  I check the residual amount of invoice should be 0 in residual currency and 0 in amount_residual and paid
+-
+  !python {model: account.invoice}: |
+    invoice_id = self.browse(cr, uid, ref("account_invoice_eur_usd"))
+    move_line_obj = self.pool.get('account.move.line')
+    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
+    move_line = move_line_obj.browse(cr, uid, move_lines[0])
+    assert (move_line.amount_residual_currency == 0.0 and move_line.amount_residual == 0.0 and invoice_id.state == 'paid') , "Residual amount is not correct for Invoice"
+    

=== added file 'account_voucher_supplier_invoice_number/test/sales_payment.yml'
--- account_voucher_supplier_invoice_number/test/sales_payment.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/sales_payment.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,71 @@
+-
+  Create an invoice for the partner Seagate with amount 450.0
+-
+  !record {model: account.invoice, id: account_invoice_0}:
+    account_id: account.a_recv
+    company_id: base.main_company
+    currency_id: base.EUR
+    invoice_line:
+      - account_id: account.a_sale
+        name: '[PCSC234] PC Assemble SC234'
+        price_unit: 450.0
+        quantity: 1.0
+        product_id: product.product_product_3
+        uos_id: product.product_uom_unit
+    journal_id: account.sales_journal
+    partner_id: base.res_partner_19
+
+-
+  I check that the customer invoice is in draft state
+-
+  !assert {model: account.invoice, id: account_invoice_0}:
+    - state == 'draft'
+
+-
+  I make the invoice in Open state
+-
+  !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}
+
+-
+  I check that a payment entry gets created in the account.move.line
+-
+  !python {model: account.invoice}: |
+    acc_id=self.browse(cr, uid, ref("account_invoice_0"))
+    assert(acc_id.move_id)
+
+-
+  I will create and post an account voucher of amount 450.0 for the partner Seagate.
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    vals = {}
+    journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
+    res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
+    vals = {
+        'account_id': ref('account.cash'),
+        'amount': 450.0,
+        'company_id': ref('base.main_company'),
+        'journal_id': ref('account.bank_journal'),
+        'partner_id': ref('base.res_partner_19'),
+        'period_id': ref('account.period_8'),
+        'type': 'receipt',
+    }
+    if not res['value']['line_cr_ids']:
+      res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
+    #clients aren't sending value of readonly fields in the view, and there is a good reason for that, so here the
+    #create should only use values of fields that are not readonly. That's why i'm removing some of these values
+    del(res['value']['line_cr_ids'][0]['date_original'])
+    del(res['value']['line_cr_ids'][0]['date_due'])
+    res['value']['line_cr_ids'][0]['amount'] = 450.0
+    vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
+    id = self.create(cr, uid, vals)
+    voucher_id = self.browse(cr, uid, id)
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
+
+-
+  Finally i will Confirm the state of the invoice is paid
+-
+  !assert {model: account.invoice, id: account_invoice_0}:
+    - state == 'paid'

=== added file 'account_voucher_supplier_invoice_number/test/sales_receipt.yml'
--- account_voucher_supplier_invoice_number/test/sales_receipt.yml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/sales_receipt.yml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,79 @@
+- 
+  Creating a Voucher Receipt for partner Seagate with amount 30000.0
+- 
+  !record {model: account.voucher, id: account_voucher_seagate_0, view: account_voucher.view_sale_receipt_form}:
+    account_id: account.a_recv
+    amount: 30000.0
+    company_id: base.main_company
+    journal_id: account.sales_journal
+    line_cr_ids:
+      - account_id: account.a_sale
+        amount: 30000.0
+        type: cr
+    partner_id: base.res_partner_19
+    period_id: account.period_9
+    type: sale
+    
+-
+  I check that the voucher state is Draft
+-
+  !assert {model: account.voucher, id: account_voucher_seagate_0}:
+    - state == 'draft'
+
+-
+  I click on post button to post the voucher
+-
+  !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_seagate_0}
+
+-
+  Check that the voucher state is Posted
+-
+  !assert {model: account.voucher, id: account_voucher_seagate_0}:
+    - state == 'posted'
+    
+-
+  I check that move lines are validated but not reconciled
+-
+  !python {model: account.voucher}: |
+    reconciled = False
+    for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: 
+       if l.reconcile_id:
+         reconciled = True
+         break
+    assert (not reconciled), "Found reconciled move lines, should not be"
+-
+  I create and post a voucher payment of amount 30000.0 for the partner Seagate
+-
+  !python {model: account.voucher}: |
+    import netsvc
+    vals = {}
+    journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
+    res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
+    vals = {
+        'account_id': ref('account.cash'),
+        'amount': 30000.0,
+        'company_id': ref('base.main_company'),
+        'journal_id': ref('account.bank_journal'),
+        'partner_id': ref('base.res_partner_19'),
+        'period_id': ref('account.period_8'),
+        'type': 'receipt',
+    }
+    if not res['value']['line_cr_ids']:
+      res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
+    res['value']['line_cr_ids'][0]['amount'] = 30000.0
+    vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
+    id = self.create(cr, uid, vals)
+    voucher_id = self.browse(cr, uid, id)
+    assert (voucher_id.state=='draft'), "Voucher is not in draft state"
+    wf_service = netsvc.LocalService("workflow")
+    wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
+-
+  I check that move lines are reconciled meaning voucher is paid
+-
+  !python {model: account.voucher}: |
+    reconciled = False
+    for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: 
+       if l.reconcile_id:
+         reconciled = True
+         break
+    assert reconciled, "Found unreconciled move lines/unpaid voucher"

=== added file 'account_voucher_supplier_invoice_number/voucher.py'
--- account_voucher_supplier_invoice_number/voucher.py	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/voucher.py	2013-05-24 13:58:47 +0000
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import fields, orm
+from tools.translate import _
+
+class voucher_line(orm.Model):
+    _inherit = 'account.voucher.line'
+    
+    def get_suppl_inv_num(self, cr, uid, move_line_id, context=None):
+        move_line = self.pool.get('account.move.line').browse(cr, uid, move_line_id, context)
+        return (move_line.invoice and move_line.invoice.supplier_invoice_number or '')
+    
+    def _get_supplier_invoice_number(self, cr, uid, ids, name, args, context=None):
+        res={}
+        for line in self.browse(cr, uid, ids, context):
+            res[line.id] = ''
+            if line.move_line_id:
+                res[line.id] = self.get_suppl_inv_num(cr, uid,
+                    line.move_line_id.id, context=context)
+        return res
+    
+    _columns = {
+        'supplier_invoice_number': fields.function(_get_supplier_invoice_number, type='char', size=64, string="Supplier Invoice Number"),
+        }
+
+class voucher(orm.Model):
+    _inherit = 'account.voucher'
+    
+    def recompute_voucher_lines(self, cr, uid, ids, partner_id, journal_id, price,
+        currency_id, ttype, date, context=None):
+        res = super(voucher,self).recompute_voucher_lines(cr, uid, ids, partner_id,
+            journal_id, price,
+            currency_id, ttype, date, context=context)
+        line_obj = self.pool.get('account.voucher.line')
+        if res.get('value') and res['value'].get('line_cr_ids'):
+            for vals in res['value']['line_cr_ids']:
+                if vals.get('move_line_id'):
+                    vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num(
+                        cr, uid, vals['move_line_id'], context=context)
+        if res.get('value') and res['value'].get('line_dr_ids'):
+            for vals in res['value']['line_dr_ids']:
+                if vals.get('move_line_id'):
+                    vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num(
+                        cr, uid, vals['move_line_id'], context=context)
+        return res

=== added file 'account_voucher_supplier_invoice_number/voucher_view.xml'
--- account_voucher_supplier_invoice_number/voucher_view.xml	1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/voucher_view.xml	2013-05-24 13:58:47 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+        <!-- Supplier Payment -->
+        <record model="ir.ui.view" id="view_vendor_payment_form">
+            <field name="name">account.voucher.payment.form</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"></field>
+            <field name="arch" type="xml">
+                <xpath expr="/form/sheet/notebook/page/field[@name='line_dr_ids']/tree/field[@name='move_line_id']" position="after">
+                    <field name="supplier_invoice_number" />
+                </xpath>
+                <xpath expr="/form/sheet/notebook/page/field[@name='line_cr_ids']/tree/field[@name='move_line_id']" position="after">
+                    <field name="supplier_invoice_number" />
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>


Follow ups