From 1eae823bf8445820e41700d378c534c11f4b1101 Mon Sep 17 00:00:00 2001 From: resteve Date: Wed, 2 Dec 2015 17:59:58 +0100 Subject: [PATCH] Test Scenario rst --- tests/scenario_sale_payment.rst | 136 +++++++------------------------- 1 file changed, 28 insertions(+), 108 deletions(-) diff --git a/tests/scenario_sale_payment.rst b/tests/scenario_sale_payment.rst index 6cf13df..3fe55d2 100644 --- a/tests/scenario_sale_payment.rst +++ b/tests/scenario_sale_payment.rst @@ -9,6 +9,12 @@ Imports:: >>> from decimal import Decimal >>> from operator import attrgetter >>> 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() Create database:: @@ -25,29 +31,8 @@ Install sale:: Create company:: - >>> Currency = Model.get('currency.currency') - >>> CurrencyRate = Model.get('currency.currency.rate') - >>> 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([]) + >>> _ = create_company() + >>> company = get_company() Reload the context:: @@ -57,91 +42,28 @@ Reload the context:: Create fiscal year:: - >>> FiscalYear = Model.get('account.fiscalyear') - >>> Sequence = Model.get('ir.sequence') - >>> SequenceStrict = Model.get('ir.sequence.strict') - >>> fiscalyear = FiscalYear(name=str(today.year)) - >>> 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) + >>> fiscalyear = set_fiscalyear_invoice_sequences( + ... create_fiscalyear(company)) + >>> fiscalyear.click('create_period') + >>> period = fiscalyear.periods[0] Create chart of accounts:: - >>> AccountTemplate = Model.get('account.account.template') - >>> Account = Model.get('account.account') - >>> Journal = Model.get('account.journal') - >>> account_template, = AccountTemplate.find([('parent', '=', None)]) - >>> create_chart = Wizard('account.create_chart') - >>> create_chart.execute('account') - >>> 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_chart(company) + >>> accounts = get_accounts(company) + >>> receivable = accounts['receivable'] + >>> revenue = accounts['revenue'] + >>> expense = accounts['expense'] + >>> cash = accounts['cash'] Create tax:: - >>> TaxCode = Model.get('account.tax.code') - >>> 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 = set_tax_code(create_tax(Decimal('.10'))) >>> 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:: @@ -181,16 +103,13 @@ Create product:: Create payment term:: - >>> PaymentTerm = Model.get('account.invoice.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 = create_payment_term() >>> payment_term.save() Create a shop:: >>> Shop = Model.get('sale.shop') + >>> Sequence = Model.get('ir.sequence') >>> PriceList = Model.get('product.price_list') >>> Location = Model.get('stock.location') >>> warehouse, = Location.find([ @@ -213,6 +132,7 @@ Create a shop:: Create journals:: >>> StatementJournal = Model.get('account.statement.journal') + >>> Journal = Model.get('account.journal') >>> sequence = Sequence(name='Satement', ... code='account.journal', ... company=company, @@ -302,7 +222,7 @@ Open statements for current device:: >>> open_statment = Wizard('open.statement') >>> open_statment.execute('create_') >>> open_statment.form.result - u'Statement Default opened.\n' + u'Statement Default opened. \n' >>> payment_statement, = Statement.find([('state', '=', 'draft')]) Partially pay the sale:: @@ -368,7 +288,7 @@ When the statement is closed the invoices are paid and sale is done:: >>> close_statment = Wizard('close.statement') >>> close_statment.execute('validate') >>> close_statment.form.result - u'Statement Default - Default closed.\n' + u'Statement Default - Default closed. \n' >>> payment_statement.reload() >>> payment_statement.state u'validated'