Add test scenario

issue8404
review277401005
This commit is contained in:
Sergi Almacellas Abellana committed 2019-06-06 19:19:03 +02:00
1 parent 045900b102
commit f6f6f25cd2
2 files changed
+108

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
==============================
Stock Supply Forecast Scenario
==============================
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> 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_chart,
... get_accounts)
>>> today = datetime.date.today()
>>> yesterday = today - relativedelta(days=1)
>>> tomorrow = today + relativedelta(days=1)
Install stock_supply Module::
>>> config = activate_modules('stock_supply_forecast')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> expense = accounts['expense']
Create parties::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.save()
>>> supplier = Party(name='Supplier')
>>> supplier.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('20')
>>> template.purchasable = True
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
Get warehouse location::
>>> Location = Model.get('stock.location')
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
Create a forecast::
>>> Forecast = Model.get('stock.forecast')
>>> forecast = Forecast()
>>> forecast.warehouse = warehouse_loc
>>> forecast.from_date = yesterday
>>> forecast.to_date = tomorrow
>>> forecast_line = forecast.lines.new()
>>> forecast_line.product = product
>>> forecast_line.quantity = 10
>>> forecast.save()
There is no purchase request::
>>> create_pr = Wizard('stock.supply')
>>> create_pr.execute('create_')
>>> PurchaseRequest = Model.get('purchase.request')
>>> PurchaseRequest.find([])
[]
There is a draft purchase request after confirming the forecast::
>>> forecast.click('confirm')
>>> create_pr = Wizard('stock.supply')
>>> create_pr.execute('create_')
>>> pr, = PurchaseRequest.find([('state', '=', 'draft')])
>>> pr.product == product
True
>>> pr.quantity
5.0
+7
View File
@@ -1,8 +1,11 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_teardown
from trytond.tests.test_tryton import doctest_checker
class StockSupplyForecastTestCase(ModuleTestCase):
@@ -14,4 +17,8 @@ def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
StockSupplyForecastTestCase))
suite.addTests(doctest.DocFileSuite('scenario_stock_supply_forecast.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite