account_voucher multicurrency scenario

bzr revid: al@openerp.com-20110927163709-08ja2ruir230c6hu
This commit is contained in:
Antony Lesuisse 2011-09-27 18:37:09 +02:00
parent d14bd88ba8
commit 14ba370293
5 changed files with 1568 additions and 0 deletions

View File

@ -0,0 +1,355 @@
-
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 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')])
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 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
view_id: account.account_journal_bank_view
-
I set up some accounts for currency rate expense/income in my company
-
!record {model: res.company, id: base.main_company}:
property_expense_currency_exchange: account.o_expense
property_income_currency_exchange: account.o_income
-
I create new partner Mark Strauss.
-
!record {model: res.partner, id: res_partner_strauss0}:
address:
- city: paris
country_id: base.fr
name: Mark Strauss
street: 1 rue Rockfeller
type: invoice
zip: '75016'
name: Mr. Mark Strauss
-
I create the first invoice on 1st January for 200 USD
-
!record {model: account.invoice, id: account_invoice_jan}:
account_id: account.a_recv
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 200.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_strauss0
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 100.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_strauss0
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 create the first voucher of payment
<create with values 240 USD, journal USD, and fill amounts 180 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_strauss0"), ref('bank_journal_USD'), 240.00, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 240.00,
'company_id': ref('base.main_company'),
'currency_id': ref('base.USD'),
'journal_id': ref('bank_journal_USD'),
'partner_id': ref('res_partner_strauss0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-03-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'First payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 200.00:
item['amount'] = 180.00
else:
item['amount'] = 70.00
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"
-
I check that writeoff amount computed is -10.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.writeoff_amount == -10.0), "Writeoff amount is not -10.0"
-
I check that currency rate difference is -34.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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 135 and 56
-
I check that my currency rate difference is correct. 34 in credit with no amount_currency
-
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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 == 135.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.credit == 34.00:
assert move_line.amount_currency == 0.00, "Incorrect currency rate difference."
elif move_line.amount_currency == 10.00:
assert move_line.debit == 9.00, "Writeoff amount is wrong."
-
I check the residual amount of Invoice1, should be 20 in amount_currency and 15 in company 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 and move_line.amount_residual == 15.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 and move_line.amount_residual == 24.0) , "Residual amount is not correct for first Invoice"
-
I create the second voucher of payment
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_strauss0"), ref('bank_journal_USD'), 45.00, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 45.00,
'company_id': ref('base.main_company'),
'currency_id': ref('base.USD'),
'journal_id': ref('bank_journal_USD'),
'partner_id': ref('res_partner_strauss0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-04-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'Second payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 20.00:
item['amount'] = 20.00
else:
item['amount'] = 30.00
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"
-
I check that writeoff amount computed is -5.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_strauss0'))])
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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 15 and 24.
-
I check that my currency rate difference is correct. 8.5 in credit with no amount_currency
-
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'), ('partner_id', '=', ref('res_partner_strauss0'))])
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.credit == 15.00, "Debtor account has wrong entry."
elif move_line.amount_currency == -30.00:
assert move_line.credit == 24.00, "Debtor account has wrong entry."
elif move_line.credit == 8.50:
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
elif move_line.amount_currency == 5.00:
assert move_line.debit == 4.75, "Writeoff amount is wrong."
-
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"

View File

@ -0,0 +1,328 @@
-
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 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
view_id: account.account_journal_bank_view
-
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
view_id: account.account_journal_bank_view
-
I create a new partner Robert Clements
-
!record {model: res.partner, id: res_partner_clements0}:
address:
- city: marseille
country_id: base.fr
name: Robert
street: 1 rue Rockfeller
type: invoice
zip: '13016'
name: Mr.Robert Clements
-
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 200.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_clements0
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 100.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_clements0
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 create the first voucher of payment
<create with values 240 EUR, journal EUR, and fills amount 180 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_clements0"), ref('bank_journal_EUR'), 240.0, 2, ttype='payment', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 240.0,
'company_id': ref('base.main_company'),
'currency_id': ref('base.EUR'),
'journal_id': ref('bank_journal_EUR'),
'partner_id': ref('res_partner_clements0'),
'period_id': ref('account.period_3'),
'type': 'payment',
'date': time.strftime("%Y-03-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'First payment',
}
if not res['value']['line_dr_ids']:
res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
for item in res['value']['line_dr_ids']:
if item['amount_unreconciled'] == 200.00:
item['amount'] = 180.00
else:
item['amount'] = 70.00
vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_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"
-
I check that writeoff amount computed is -15.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_clements0"), ref('bank_journal_EUR'), 45.0, 2, ttype='payment', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 45.0,
'company_id': ref('base.main_company'),
'currency_id': ref('base.USD'),
'journal_id': ref('bank_journal_USD'),
'partner_id': ref('res_partner_clements0'),
'period_id': ref('account.period_3'),
'type': 'payment',
'date': time.strftime("%Y-04-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'Second payment',
}
if not res['value']['line_dr_ids']:
res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
for item in res['value']['line_dr_ids']:
if item['amount_unreconciled'] == 20.00:
item['amount'] = 20.00
else:
item['amount'] = 30.00
vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_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"
-
I check that writeoff amount computed is -5.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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'), ('partner_id', '=', ref('res_partner_clements0'))])
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"

View File

@ -0,0 +1,360 @@
-
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 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')])
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: febr_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: marc_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: apri_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
currency: base.EUR
company_id: base.main_company
view_id: account.account_journal_bank_view
-
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
view_id: account.account_journal_bank_view
-
I set up some accounts for currency rate expense/income in my company
-
!record {model: res.company, id: base.main_company}:
property_expense_currency_exchange: account.o_expense
property_income_currency_exchange: account.o_income
-
I create a new partner Michael Geller
-
!record {model: res.partner, id: res_partner_michael0}:
address:
- city: paris
country_id: base.fr
name: Michael
street: 1 rue Rockfeller
type: invoice
zip: '75016'
name: Mr.Michael Geller
-
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 200.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_michael0
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 100.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_michael0
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 create the first voucher of payment
<create with values 240 EUR, journal EUR, and fills amount 180 for the invoice of 200$ and 70 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_michael0"), ref('bank_journal_EUR'), 240.0, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 240.0,
'company_id': ref('base.main_company'),
'currency_id': ref('base.EUR'),
'journal_id': ref('bank_journal_EUR'),
'partner_id': ref('res_partner_michael0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-03-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'First payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 200.00:
item['amount'] = 180.00
else:
item['amount'] = 70.00
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"
-
I check that writeoff amount computed is 15.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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 in amount_currency columns and their credit 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'), ('partner_id', '=', ref('res_partner_michael0'))])
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 == 135.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.credit == 34.00:
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
elif move_line.credit == 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"))
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"))
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
<create with values 45 USD, journal USD, and fill amounts 20 for the invoice of 200$ and 30 for the invoice of 100$>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_michael0"), ref('bank_journal_EUR'), 45.0, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 45.0,
'company_id': ref('base.main_company'),
'currency_id': ref('base.USD'),
'journal_id': ref('bank_journal_USD'),
'partner_id': ref('res_partner_michael0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-04-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'Second payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 20.00:
item['amount'] = 20.00
else:
item['amount'] = 30.00
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"
-
I check that writeoff amount computed is -5.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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'), ('partner_id', '=', ref('res_partner_michael0'))])
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 -20 and -30 in amount_currency columns and their credit columns are respectively 15 and 24 and currency is USD($).
-
I check that my currency rate difference is correct. 8.50 in credit with no amount_currency
-
I check that my writeoff is correct. 4.75 in debit and 5 in amount_currency
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_michael0'))])
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.credit == 15.00, "Debtor account has wrong entry."
elif move_line.amount_currency == -30.00:
assert move_line.credit == 24.00, "Debtor account has wrong entry."
elif move_line.credit == 8.50:
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
elif move_line.amount_currency == 5.00:
assert move_line.debit == 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"))
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"

View File

@ -0,0 +1,331 @@
-
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 create currency EUR in OpenERP for February of 1.000000 Rate
-
!record {model: res.currency.rate, id: feb_eur}:
currency_id: base.EUR
name: !eval "'%s-02-01' %(datetime.now().year)"
rate: 1.000000
-
I create currency EUR in OpenERP for March of 1.000000 Rate
-
!record {model: res.currency.rate, id: mar_eur}:
currency_id: base.EUR
name: !eval "'%s-03-01' %(datetime.now().year)"
rate: 1.000000
-
I create currency EUR in OpenERP for April of 1.000000 Rate
-
!record {model: res.currency.rate, id: apr_eur}:
currency_id: base.EUR
name: !eval "'%s-04-01' %(datetime.now().year)"
rate: 1.000000
-
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
view_id: account.account_journal_bank_view
-
I set up some accounts for currency rate expense/income in my company
-
!record {model: res.company, id: base.main_company}:
property_expense_currency_exchange: account.o_expense
property_income_currency_exchange: account.o_income
-
I create a new partner Peter Lawson.
-
!record {model: res.partner, id: res_partner_peter0}:
address:
- city: paris
country_id: base.fr
name: Peter
street: 1 rue Rockfeller
type: invoice
zip: '75016'
name: Mr.Peter Lawson
-
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 150.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_peter0
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 80.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_peter0
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 create the first voucher of payment
<create with values 120 EUR, journal EUR, and fill amounts 100 for the invoice of 150 EUR and 20 for the invoice of 80 EUR>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_peter0"), ref('bank_journal_EUR'), 120.00, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 120.00,
'company_id': ref('base.main_company'),
'currency_id': ref('base.EUR'),
'journal_id': ref('bank_journal_EUR'),
'partner_id': ref('res_partner_peter0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-03-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'First payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 150.00:
item['amount'] = 100.00
else:
item['amount'] = 20.00
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"
-
I check that writeoff amount computed is 0.00
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0.00"
-
I check that currency rate difference is 0.00
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.currency_rate_difference == 0.00), "Currency rate difference is not 0.00"
-
I confirm the voucher
-
!python {model: account.voucher}: |
import netsvc
voucher = self.search(cr, uid, [('name', '=', 'First payment'),('partner_id', '=', ref('res_partner_peter0'))])
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'),('partner_id', '=', ref('res_partner_peter0'))])
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'),('partner_id', '=', ref('res_partner_peter0'))])
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 and check to let open the debtor overpaid amount.
<create with values 120 EUR, journal EUR, and fill amounts 50 for the invoice of 150 EUR and 70 for the invoice of 80 EUR>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_peter0"), ref('bank_journal_EUR'), 120.00, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 120.00,
'company_id': ref('base.main_company'),
'currency_id': ref('base.EUR'),
'journal_id': ref('bank_journal_EUR'),
'partner_id': ref('res_partner_peter0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-04-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'Second payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 50.00:
item['amount'] = 50.00
elif item['amount_unreconciled'] == 60.00:
item['amount'] = 70.00
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"
-
I check that writeoff amount computed is 0.00
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'),('partner_id', '=', ref('res_partner_peter0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.writeoff_amount == 0.00), "Writeoff amount is not 0"
-
I check that currency rate difference is 0.00
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.currency_rate_difference == 0.00), "Currency rate difference is not 0"
-
I confirm the voucher
-
!python {model: account.voucher}: |
import netsvc
voucher = self.search(cr, uid, [('name', '=', 'Second payment'), ('partner_id', '=', ref('res_partner_peter0'))])
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'), ('partner_id', '=', ref('res_partner_peter0'))])
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'), ('partner_id', '=', ref('res_partner_peter0'))])
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"

View File

@ -0,0 +1,194 @@
-
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 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.250000
-
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
default_credit_account_id: account.cash
currency: base.CHF
company_id: base.main_company
view_id: account.account_journal_bank_view
-
I set up some accounts for currency rate expense/income in my company
-
!record {model: res.company, id: base.main_company}:
property_expense_currency_exchange: account.o_expense
property_income_currency_exchange: account.o_income
-
I create a new partner John Armani.
-
!record {model: res.partner, id: res_partner_john0}:
address:
- city: paris
country_id: base.fr
name: John
street: 1 rue Rockfeller
type: invoice
zip: '75016'
name: Mr.John Armani
-
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
address_contact_id: base.res_partner_address_3000
address_invoice_id: base.res_partner_address_3000
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: '[PC1] Basic PC'
price_unit: 200.0
quantity: 1.0
product_id: product.product_product_pc1
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: res_partner_john0
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 create the first voucher of payment
<create with values 300 CHF, journal CHF, and fill amounts 200 for the invoice of 200 CAD>
-
!python {model: account.voucher}: |
import netsvc, time
vals = {}
res = self.onchange_partner_id(cr, uid, [], ref("res_partner_john0"), ref('bank_journal_CHF'), 300.00, 2, ttype='receipt', date=False)
vals = {
'account_id': ref('account.cash'),
'amount': 300.00,
'company_id': ref('base.main_company'),
'currency_id': ref('base.CHF'),
'journal_id': ref('bank_journal_CHF'),
'partner_id': ref('res_partner_john0'),
'period_id': ref('account.period_3'),
'type': 'receipt',
'date': time.strftime("%Y-03-01"),
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'comment': 'Write Off',
'name': 'First payment',
}
if not res['value']['line_cr_ids']:
res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
for item in res['value']['line_cr_ids']:
if item['amount_unreconciled'] == 200.00:
item['amount'] = 200.00
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"
-
I check that writeoff amount computed is 175.0
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
voucher_id = self.browse(cr, uid, voucher[0])
assert (voucher_id.writeoff_amount == 175.0), "Writeoff amount is not 175.0"
-
I check that currency rate difference is 49.39
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
voucher_id = self.browse(cr, uid, voucher[0])
curr_diff = float(str(voucher_id.currency_rate_difference))
assert (curr_diff == 49.39), "Currency rate difference is not 49.39"
-
I confirm the voucher
-
!python {model: account.voucher}: |
import netsvc
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
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'), ('partner_id', '=', ref('res_partner_john0'))])
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 -200 as amount_currency columns and 149.39 of credit and currency is CAD($).
-
I check that my currency rate difference is correct. 49.39 in debit with no amount_currency
-
I check that my writeoff is correct. 140 credit and -175 amount_currency
-
!python {model: account.voucher}: |
voucher = self.search(cr, uid, [('name', '=', 'First payment'), ('partner_id', '=', ref('res_partner_john0'))])
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.credit == 149.39, "Debtor account has wrong entry."
elif move_line.debit == 49.39:
assert move_line.amount_currency == 0.00, "Incorrect Currency Difference."
elif move_line.credit == 140.00:
assert move_line.amount_currency == -175.00, "Writeoff amount is wrong."
-
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"