Initial import from Docker volume
This commit is contained in:
2
modules/sale_supply_production/tests/__init__.py
Executable file
2
modules/sale_supply_production/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_supply_production/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_supply_production/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_supply_production/tests/__pycache__/__init__.cpython-311.pyc
Executable file
BIN
modules/sale_supply_production/tests/__pycache__/__init__.cpython-311.pyc
Executable file
Binary file not shown.
Binary file not shown.
BIN
modules/sale_supply_production/tests/__pycache__/test_module.cpython-311.pyc
Executable file
BIN
modules/sale_supply_production/tests/__pycache__/test_module.cpython-311.pyc
Executable file
Binary file not shown.
Binary file not shown.
BIN
modules/sale_supply_production/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
BIN
modules/sale_supply_production/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
Binary file not shown.
157
modules/sale_supply_production/tests/scenario_sale_supply_production.rst
Executable file
157
modules/sale_supply_production/tests/scenario_sale_supply_production.rst
Executable file
@@ -0,0 +1,157 @@
|
||||
===============================
|
||||
Sale Supply Production Scenario
|
||||
===============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
|
||||
>>> from trytond.modules.company.tests.tools import create_company, get_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('sale_supply_production')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart(company)
|
||||
>>> accounts = get_accounts(company)
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_revenue = accounts['revenue']
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Product"
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.producible = True
|
||||
>>> template.salable = True
|
||||
>>> template.supply_on_sale = 'always'
|
||||
>>> template.list_price = Decimal(30)
|
||||
>>> template.account_category = account_category
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal(20)
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create components::
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Component 1"
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal(5)
|
||||
>>> component, = template.products
|
||||
>>> component.cost_price = Decimal(1)
|
||||
>>> template.save()
|
||||
>>> component, = template.products
|
||||
|
||||
Create bill of material::
|
||||
|
||||
>>> BOM = Model.get('production.bom')
|
||||
>>> bom = BOM(name="Product")
|
||||
>>> input = bom.inputs.new()
|
||||
>>> input.product = component
|
||||
>>> input.quantity = 5
|
||||
>>> output = bom.outputs.new()
|
||||
>>> output.product = product
|
||||
>>> output.quantity = 1
|
||||
>>> bom.save()
|
||||
|
||||
>>> product_bom = product.boms.new()
|
||||
>>> product_bom.bom = bom
|
||||
>>> product.save()
|
||||
|
||||
Sale 10 products::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 10
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
>>> shipment, = sale.shipments
|
||||
>>> move, = shipment.outgoing_moves
|
||||
>>> move.state
|
||||
'staging'
|
||||
>>> move, = shipment.inventory_moves
|
||||
>>> move.state
|
||||
'staging'
|
||||
|
||||
Check the production::
|
||||
|
||||
>>> Production = Model.get('production')
|
||||
>>> production, = Production.find([])
|
||||
>>> production.state
|
||||
'request'
|
||||
>>> assertEqual(production.origin, sale.lines[0])
|
||||
>>> assertEqual(production.product, product)
|
||||
>>> assertEqual(production.bom, bom)
|
||||
>>> production.quantity
|
||||
10.0
|
||||
|
||||
Delete the production, recreate one::
|
||||
|
||||
>>> production.delete()
|
||||
>>> production, = Production.find([])
|
||||
>>> production.quantity
|
||||
10.0
|
||||
|
||||
Start the production::
|
||||
|
||||
>>> production.click('draft')
|
||||
>>> production.click('wait')
|
||||
>>> production.click('assign_force')
|
||||
>>> production.click('run')
|
||||
>>> production.state
|
||||
'running'
|
||||
|
||||
>>> shipment.reload()
|
||||
>>> move, = shipment.outgoing_moves
|
||||
>>> move.state
|
||||
'draft'
|
||||
>>> move, = shipment.inventory_moves
|
||||
>>> move.state
|
||||
'draft'
|
||||
|
||||
Finish the production::
|
||||
|
||||
>>> production.click('do')
|
||||
|
||||
>>> shipment.reload()
|
||||
>>> move, = shipment.outgoing_moves
|
||||
>>> move.state
|
||||
'draft'
|
||||
>>> move, = shipment.inventory_moves
|
||||
>>> move.state
|
||||
'assigned'
|
||||
@@ -0,0 +1,110 @@
|
||||
===========================================
|
||||
Sale Supply Production Stock First Scenario
|
||||
===========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('sale_supply_production')
|
||||
|
||||
>>> Inventory = Model.get('stock.inventory')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> UoM = Model.get('product.uom')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart()
|
||||
>>> accounts = get_accounts()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_revenue = accounts['revenue']
|
||||
>>> account_category.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> unit, = UoM.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Product"
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.producible = True
|
||||
>>> template.salable = True
|
||||
>>> template.supply_on_sale = 'stock_first'
|
||||
>>> template.list_price = Decimal(30)
|
||||
>>> template.account_category = account_category
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal(20)
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Fill warehouse::
|
||||
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location, = Location.find([('code', '=', 'STO')])
|
||||
>>> line = inventory.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 5
|
||||
>>> inventory.click('confirm')
|
||||
>>> inventory.state
|
||||
'done'
|
||||
|
||||
Sale 3 products without production request::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 3
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
>>> line, = sale.lines
|
||||
>>> len(line.productions)
|
||||
0
|
||||
>>> move, = line.moves
|
||||
>>> move.state
|
||||
'draft'
|
||||
|
||||
Sale 4 products with production request::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 4
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.state
|
||||
'processing'
|
||||
>>> line, = sale.lines
|
||||
>>> len(line.productions)
|
||||
1
|
||||
>>> move, = line.moves
|
||||
>>> move.state
|
||||
'staging'
|
||||
12
modules/sale_supply_production/tests/test_module.py
Executable file
12
modules/sale_supply_production/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 SaleSupplyProductionTestCase(ModuleTestCase):
|
||||
'Test Sale Supply Production module'
|
||||
module = 'sale_supply_production'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_supply_production/tests/test_scenario.py
Executable file
8
modules/sale_supply_production/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