Test Scenario rst

This commit is contained in:
resteve 2015-12-02 17:59:58 +01:00
parent 72c1e369e6
commit 1eae823bf8

View File

@ -9,6 +9,12 @@ Imports::
>>> from decimal import Decimal >>> from decimal import Decimal
>>> from operator import attrgetter >>> from operator import attrgetter
>>> from proteus import config, Model, Wizard >>> from proteus import config, Model, Wizard
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts, create_tax, set_tax_code
>>> from.trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> today = datetime.date.today() >>> today = datetime.date.today()
Create database:: Create database::
@ -25,29 +31,8 @@ Install sale::
Create company:: Create company::
>>> Currency = Model.get('currency.currency') >>> _ = create_company()
>>> CurrencyRate = Model.get('currency.currency.rate') >>> company = get_company()
>>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
... currency = Currency(name='U.S. Dollar', symbol='$', code='USD',
... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
... mon_decimal_point='.', mon_thousands_sep=',')
... currency.save()
... CurrencyRate(date=today + relativedelta(month=1, day=1),
... rate=Decimal('1.0'), currency=currency).save()
... else:
... currency, = currencies
>>> Company = Model.get('company.company')
>>> Party = Model.get('party.party')
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
>>> party = Party(name='Dunder Mifflin')
>>> party.save()
>>> company.party = party
>>> company.currency = currency
>>> company_config.execute('add')
>>> company, = Company.find([])
Reload the context:: Reload the context::
@ -57,91 +42,28 @@ Reload the context::
Create fiscal year:: Create fiscal year::
>>> FiscalYear = Model.get('account.fiscalyear') >>> fiscalyear = set_fiscalyear_invoice_sequences(
>>> Sequence = Model.get('ir.sequence') ... create_fiscalyear(company))
>>> SequenceStrict = Model.get('ir.sequence.strict') >>> fiscalyear.click('create_period')
>>> fiscalyear = FiscalYear(name=str(today.year)) >>> period = fiscalyear.periods[0]
>>> fiscalyear.start_date = today + relativedelta(month=1, day=1)
>>> fiscalyear.end_date = today + relativedelta(month=12, day=31)
>>> fiscalyear.company = company
>>> post_move_seq = Sequence(name=str(today.year), code='account.move',
... company=company)
>>> post_move_seq.save()
>>> fiscalyear.post_move_sequence = post_move_seq
>>> invoice_seq = SequenceStrict(name=str(today.year),
... code='account.invoice', company=company)
>>> invoice_seq.save()
>>> fiscalyear.out_invoice_sequence = invoice_seq
>>> fiscalyear.in_invoice_sequence = invoice_seq
>>> fiscalyear.out_credit_note_sequence = invoice_seq
>>> fiscalyear.in_credit_note_sequence = invoice_seq
>>> fiscalyear.save()
>>> FiscalYear.create_period([fiscalyear.id], config.context)
Create chart of accounts:: Create chart of accounts::
>>> AccountTemplate = Model.get('account.account.template') >>> _ = create_chart(company)
>>> Account = Model.get('account.account') >>> accounts = get_accounts(company)
>>> Journal = Model.get('account.journal') >>> receivable = accounts['receivable']
>>> account_template, = AccountTemplate.find([('parent', '=', None)]) >>> revenue = accounts['revenue']
>>> create_chart = Wizard('account.create_chart') >>> expense = accounts['expense']
>>> create_chart.execute('account') >>> cash = accounts['cash']
>>> create_chart.form.account_template = account_template
>>> create_chart.form.company = company
>>> create_chart.execute('create_account')
>>> receivable, = Account.find([
... ('kind', '=', 'receivable'),
... ('company', '=', company.id),
... ])
>>> payable, = Account.find([
... ('kind', '=', 'payable'),
... ('company', '=', company.id),
... ])
>>> revenue, = Account.find([
... ('kind', '=', 'revenue'),
... ('company', '=', company.id),
... ])
>>> expense, = Account.find([
... ('kind', '=', 'expense'),
... ('company', '=', company.id),
... ])
>>> create_chart.form.account_receivable = receivable
>>> create_chart.form.account_payable = payable
>>> create_chart.execute('create_properties')
>>> cash, = Account.find([
... ('name', '=', 'Main Cash'),
... ('company', '=', company.id),
... ])
>>> account_tax, = Account.find([
... ('kind', '=', 'other'),
... ('company', '=', company.id),
... ('name', '=', 'Main Tax'),
... ])
Create tax:: Create tax::
>>> TaxCode = Model.get('account.tax.code') >>> tax = set_tax_code(create_tax(Decimal('.10')))
>>> Tax = Model.get('account.tax')
>>> tax = Tax()
>>> tax.name = 'Tax'
>>> tax.description = 'Tax'
>>> tax.type = 'percentage'
>>> tax.rate = Decimal('.10')
>>> tax.invoice_account = account_tax
>>> tax.credit_note_account = account_tax
>>> invoice_base_code = TaxCode(name='invoice base')
>>> invoice_base_code.save()
>>> tax.invoice_base_code = invoice_base_code
>>> invoice_tax_code = TaxCode(name='invoice tax')
>>> invoice_tax_code.save()
>>> tax.invoice_tax_code = invoice_tax_code
>>> credit_note_base_code = TaxCode(name='credit note base')
>>> credit_note_base_code.save()
>>> tax.credit_note_base_code = credit_note_base_code
>>> credit_note_tax_code = TaxCode(name='credit note tax')
>>> credit_note_tax_code.save()
>>> tax.credit_note_tax_code = credit_note_tax_code
>>> tax.save() >>> tax.save()
>>> invoice_base_code = tax.invoice_base_code
>>> invoice_tax_code = tax.invoice_tax_code
>>> credit_note_base_code = tax.credit_note_base_code
>>> credit_note_tax_code = tax.credit_note_tax_code
Create parties:: Create parties::
@ -181,16 +103,13 @@ Create product::
Create payment term:: Create payment term::
>>> PaymentTerm = Model.get('account.invoice.payment_term') >>> payment_term = create_payment_term()
>>> PaymentTermLine = Model.get('account.invoice.payment_term.line')
>>> payment_term = PaymentTerm(name='Direct')
>>> payment_term_line = PaymentTermLine(type='remainder', days=0)
>>> payment_term.lines.append(payment_term_line)
>>> payment_term.save() >>> payment_term.save()
Create a shop:: Create a shop::
>>> Shop = Model.get('sale.shop') >>> Shop = Model.get('sale.shop')
>>> Sequence = Model.get('ir.sequence')
>>> PriceList = Model.get('product.price_list') >>> PriceList = Model.get('product.price_list')
>>> Location = Model.get('stock.location') >>> Location = Model.get('stock.location')
>>> warehouse, = Location.find([ >>> warehouse, = Location.find([
@ -213,6 +132,7 @@ Create a shop::
Create journals:: Create journals::
>>> StatementJournal = Model.get('account.statement.journal') >>> StatementJournal = Model.get('account.statement.journal')
>>> Journal = Model.get('account.journal')
>>> sequence = Sequence(name='Satement', >>> sequence = Sequence(name='Satement',
... code='account.journal', ... code='account.journal',
... company=company, ... company=company,