[REF] account: rewrite the sequence test in YAML

bzr revid: ls@numerigraphe.fr-20100713155313-cw7e9l5gjhfkba70
This commit is contained in:
Numerigraphe - Lionel Sausin 2010-07-13 17:53:13 +02:00
parent 0b510c2798
commit a9a8c13e68
3 changed files with 46 additions and 54 deletions

View File

@ -124,10 +124,10 @@ module named account_vouchers
'project/analytic_account_demo.xml',
'demo/account_minimal.xml',
'account_unit_test.xml',
'test/sequence_bug602188_test.xml',
'board_account_demo.xml',
],
'test': [
'test/account_sequence_test.yml',
'test/account_customer_invoice.yml',
'test/account_supplier_invoice.yml',
'test/account_change_currency.yml',

View File

@ -0,0 +1,45 @@
- In order to test the invoice numbering, I create a sequence for out invoices.
- !record {model: ir.sequence, id: seq_out_invoice_test}:
name: Account Invoice Out for the demonstration Fiscal Year # XXX indicate the name of the fiscal year
code: account.invoice.out_invoice
padding: 3
prefix: FY-
suffix: -TEST
number_next: 42
- I link the new sequence to the demo sequence and the demo fiscal years.
- !record {model: account.sequence.fiscalyear, id: seq_out_invoice_test_fy}:
sequence_id: seq_out_invoice_test
sequence_main_id: seq_out_invoice
fiscalyear_id: data_fiscalyear
- I create a draft customer invoice in a period of the demo fiscal year
- !record {model: account.invoice, id: invoice_seq_test}:
account_id: account.a_recv
address_contact_id: base.res_partner_address_zen
address_invoice_id: base.res_partner_address_zen
company_id: base.main_company
currency_id: base.EUR
invoice_line:
- account_id: account.a_sale
name: '[PC3] Medium PC'
price_unit: 900.0
quantity: 10.0
product_id: product.product_product_pc3
uos_id: product.product_uom_unit
journal_id: account.sales_journal
partner_id: base.res_partner_3
reference_type: none
period_id: period_1
- I create the invoice, as is I clicked on the "Create" button
- !workflow {model: account.invoice, action: invoice_open, ref: invoice_seq_test}
- I check that the invoice state is "Open"
- !assert {model: account.invoice, id: invoice_seq_test}:
- state == 'open'
- I check that the invoice got the right number using our sequence
# This used to fail because of bug #602188
- !assert {model: account.invoice, id: invoice_seq_test}:
- number == 'FY-042-TEST'

View File

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Make sure bug #602188 is fixed: Wrong invoice number sequence for
fiscal year in a certain case
-->
<!-- This file must be loaded _after_ account_demo.xml ! -->
<!-- New invoice sequence for a fiscal year -->
<record id="seq_out_invoice_bug602188" model="ir.sequence">
<field eval="'Account Invoice Out for Fiscal Year '+time.strftime('%Y')"
name="name" />
<field name="code">account.invoice.out_invoice</field>
<field name="padding" eval="3" />
<field name="prefix">TEST-</field>
<field name="suffix">-bug602188</field>
<field name="number_next" eval="42" />
<field name="active" eval="True" />
</record>
<record id="seq_out_invoice_bug602188_fy" model="account.sequence.fiscalyear">
<field name="sequence_id" ref="seq_out_invoice_bug602188" />
<field name="sequence_main_id" ref="seq_out_invoice" />
<field name="fiscalyear_id" ref="data_fiscalyear" />
</record>
<!-- New invoice using the sequence -->
<record id="invoice_bug602188" model="account.invoice">
<field name="currency_id" ref="base.EUR" />
<field name="company_id" ref="base.main_company" />
<field name="address_invoice_id" ref="base.res_partner_address_tang" />
<field name="partner_id" ref="base.res_partner_asus" />
<field name="journal_id" ref="account.sales_journal" />
<field name="state">draft</field>
<field name="type">out_invoice</field>
<field name="account_id" ref="account.a_recv" />
<field name="name">lp:602188</field>
<field name="address_contact_id" ref="base.res_partner_address_tang" />
<field name="period_id" ref="period_1" />
</record>
<workflow action="invoice_open" model="account.invoice" ref="invoice_bug602188" />
<assert id="invoice_bug602188" model="account.invoice" severity="error"
string="Invoice lp:602188 got the right number">
<test expr="state">open</test>
<test expr="number">TEST-042-bug602188</test>
</assert>
<!-- Deactivate the sequence to not make other tests fail -->
<record id="seq_out_invoice_bug602188" model="ir.sequence">
<field name="active" eval="False" />
</record>
</data>
</openerp>