Initial import from Docker volume
This commit is contained in:
2
modules/sale_stock_quantity/tests/__init__.py
Executable file
2
modules/sale_stock_quantity/tests/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/sale_stock_quantity/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_stock_quantity/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_stock_quantity/tests/__pycache__/__init__.cpython-311.pyc
Executable file
BIN
modules/sale_stock_quantity/tests/__pycache__/__init__.cpython-311.pyc
Executable file
Binary file not shown.
BIN
modules/sale_stock_quantity/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_stock_quantity/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_stock_quantity/tests/__pycache__/test_module.cpython-311.pyc
Executable file
BIN
modules/sale_stock_quantity/tests/__pycache__/test_module.cpython-311.pyc
Executable file
Binary file not shown.
Binary file not shown.
BIN
modules/sale_stock_quantity/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
BIN
modules/sale_stock_quantity/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
Binary file not shown.
205
modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
Executable file
205
modules/sale_stock_quantity/tests/scenario_sale_stock_quantity.rst
Executable file
@@ -0,0 +1,205 @@
|
||||
===================
|
||||
Sale Stock Quantity
|
||||
===================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import (
|
||||
... create_chart, create_fiscalyear, get_accounts)
|
||||
>>> from trytond.modules.account_invoice.tests.tools import (
|
||||
... create_payment_term, set_fiscalyear_invoice_sequences)
|
||||
>>> from trytond.modules.company.tests.tools import create_company, get_company
|
||||
>>> from trytond.modules.stock.exceptions import InventoryFutureWarning
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> later = today + dt.timedelta(days=2)
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(['sale_stock_quantity', 'stock_supply'])
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(company, (today, later)))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart(company)
|
||||
>>> accounts = get_accounts(company)
|
||||
>>> revenue = accounts['revenue']
|
||||
>>> 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.account_revenue = revenue
|
||||
>>> account_category.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.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_category = account_category
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> ProductSupplier = Model.get('purchase.product_supplier')
|
||||
>>> product_supplier = ProductSupplier()
|
||||
>>> product_supplier.template = template
|
||||
>>> product_supplier.party = supplier
|
||||
>>> product_supplier.lead_time = dt.timedelta(3)
|
||||
>>> product_supplier.save()
|
||||
|
||||
Create payment term::
|
||||
|
||||
>>> payment_term = create_payment_term()
|
||||
>>> payment_term.save()
|
||||
|
||||
Create an Inventory of 5 products::
|
||||
|
||||
>>> Inventory = Model.get('stock.inventory')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> storage, = Location.find([
|
||||
... ('code', '=', 'STO'),
|
||||
... ])
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location = storage
|
||||
>>> inventory_line = inventory.lines.new(product=product)
|
||||
>>> inventory_line.quantity = 5.0
|
||||
>>> inventory_line.expected_quantity = 0.0
|
||||
>>> inventory.click('confirm')
|
||||
>>> inventory.state
|
||||
'done'
|
||||
|
||||
Sale 3 products with enough stock::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 3.0
|
||||
>>> len(sale_line.notifications())
|
||||
0
|
||||
>>> sale.click('quote')
|
||||
|
||||
Sale 1 product with still enough stock::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 1.0
|
||||
>>> len(sale_line.notifications())
|
||||
0
|
||||
>>> sale.click('quote')
|
||||
|
||||
Sale 2 more products with not enough stock::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> len(sale_line.notifications())
|
||||
0
|
||||
>>> sale.click('quote')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
StockQuantityWarning: ...
|
||||
|
||||
Clean sales::
|
||||
|
||||
>>> Sale.delete(Sale.find([]))
|
||||
|
||||
Sale 6 products with not enough stock::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 6.0
|
||||
>>> len(sale_line.notifications())
|
||||
1
|
||||
>>> sale.click('quote')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
StockQuantityWarning: ...
|
||||
>>> sale.delete()
|
||||
|
||||
Make an inventory of 3 products in 2 days::
|
||||
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location = storage
|
||||
>>> inventory.date = later
|
||||
>>> inventory_line = inventory.lines.new(product=product)
|
||||
>>> inventory_line.quantity = 3.0
|
||||
>>> inventory_line.expected_quantity = 5.0
|
||||
>>> try:
|
||||
... inventory.click('confirm')
|
||||
... except InventoryFutureWarning as e:
|
||||
... Model.get('res.user.warning')(user=config.user, name=e.name).save()
|
||||
>>> inventory.click('confirm')
|
||||
>>> inventory.state
|
||||
'done'
|
||||
|
||||
Sale 4 products with not enough forecast::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 4.0
|
||||
>>> sale.click('quote')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
StockQuantityWarning: ...
|
||||
>>> sale.delete()
|
||||
|
||||
Sale 2 products with enough forecast::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.payment_term = payment_term
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 2.0
|
||||
>>> sale.click('quote')
|
||||
>>> sale.delete()
|
||||
12
modules/sale_stock_quantity/tests/test_module.py
Executable file
12
modules/sale_stock_quantity/tests/test_module.py
Executable file
@@ -0,0 +1,12 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleStockQuantityTestCase(ModuleTestCase):
|
||||
'Test Sale Stock Quantity module'
|
||||
module = 'sale_stock_quantity'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_stock_quantity/tests/test_scenario.py
Executable file
8
modules/sale_stock_quantity/tests/test_scenario.py
Executable file
@@ -0,0 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user