mirror of
https://gitlab.com/datalifeit/trytond-sale_shipping_date
synced 2023-12-14 06:52:56 +01:00
115 lines
3.4 KiB
ReStructuredText
115 lines
3.4 KiB
ReStructuredText
===========================
|
|
Sale Shipping Date Scenario
|
|
===========================
|
|
|
|
Imports::
|
|
|
|
>>> import datetime
|
|
>>> from dateutil.relativedelta import relativedelta
|
|
>>> from decimal import Decimal
|
|
>>> from operator import attrgetter
|
|
>>> from proteus import Model, Wizard, Report
|
|
>>> from trytond.tests.tools import activate_modules
|
|
>>> 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
|
|
>>> from trytond.modules.account_invoice.tests.tools import \
|
|
... set_fiscalyear_invoice_sequences, create_payment_term
|
|
>>> today = datetime.date.today()
|
|
|
|
Install sale_shipping_date::
|
|
|
|
>>> config = activate_modules('sale_shipping_date')
|
|
|
|
Create company::
|
|
|
|
>>> _ = create_company()
|
|
>>> company = get_company()
|
|
|
|
Create fiscal year::
|
|
|
|
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
|
... create_fiscalyear(company))
|
|
>>> fiscalyear.click('create_period')
|
|
|
|
Create chart of accounts::
|
|
|
|
>>> _ = create_chart(company)
|
|
>>> accounts = get_accounts(company)
|
|
>>> revenue = accounts['revenue']
|
|
>>> expense = accounts['expense']
|
|
|
|
Create tax::
|
|
|
|
>>> tax = create_tax(Decimal('.10'))
|
|
>>> tax.save()
|
|
|
|
Create parties::
|
|
|
|
>>> Party = Model.get('party.party')
|
|
>>> supplier = Party(name='Supplier')
|
|
>>> supplier.save()
|
|
>>> customer = Party(name='Customer')
|
|
>>> customer.save()
|
|
|
|
Create account categories::
|
|
|
|
>>> ProductCategory = Model.get('product.category')
|
|
>>> account_category = ProductCategory(name="Account Category")
|
|
>>> account_category.accounting = True
|
|
>>> account_category.account_expense = expense
|
|
>>> account_category.account_revenue = revenue
|
|
>>> account_category.save()
|
|
|
|
>>> account_category_tax, = account_category.duplicate()
|
|
>>> account_category_tax.customer_taxes.append(tax)
|
|
>>> account_category_tax.save()
|
|
|
|
Create product::
|
|
|
|
>>> ProductUom = Model.get('product.uom')
|
|
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
|
>>> ProductTemplate = Model.get('product.template')
|
|
|
|
>>> template = ProductTemplate()
|
|
>>> template.name = 'product'
|
|
>>> template.default_uom = unit
|
|
>>> template.type = 'goods'
|
|
>>> template.salable = True
|
|
>>> template.list_price = Decimal('10')
|
|
>>> template.account_category = account_category_tax
|
|
>>> template.save()
|
|
>>> product, = template.products
|
|
|
|
Create payment term::
|
|
|
|
>>> payment_term = create_payment_term()
|
|
>>> payment_term.save()
|
|
|
|
Sale 2 products::
|
|
|
|
>>> Sale = Model.get('sale.sale')
|
|
>>> SaleLine = Model.get('sale.line')
|
|
>>> sale = Sale()
|
|
>>> sale.party = customer
|
|
>>> sale.payment_term = payment_term
|
|
>>> sale.planned_shipping_date = today
|
|
>>> sale.invoice_method = 'order'
|
|
>>> sale_line = SaleLine()
|
|
>>> sale.lines.append(sale_line)
|
|
>>> sale_line.product = product
|
|
>>> sale_line.quantity = 2.0
|
|
>>> sale_line.manual_shipping_date == today
|
|
True
|
|
>>> sale_line = SaleLine()
|
|
>>> sale.lines.append(sale_line)
|
|
>>> sale_line.product = product
|
|
>>> sale_line.quantity = 3.0
|
|
>>> sale_line.manual_shipping_date = today + relativedelta(days=2)
|
|
>>> sale.click('quote')
|
|
>>> sale.click('confirm')
|
|
>>> sale.state
|
|
'processing'
|
|
>>> len(sale.shipments), len(sale.shipment_returns)
|
|
(2, 0) |