first commit
This commit is contained in:
2
modules/stock_product_location/tests/__init__.py
Normal file
2
modules/stock_product_location/tests/__init__.py
Normal 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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
=============================
|
||||
Product Copy Locaton Scenario
|
||||
=============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_product_location', create_company)
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
|
||||
Create new location::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> child_loc = Location()
|
||||
>>> child_loc.name = 'Child Location'
|
||||
>>> child_loc.parent = storage_loc
|
||||
>>> child_loc.code = 'CHI'
|
||||
>>> child_loc.save()
|
||||
|
||||
Create a product with suppliers::
|
||||
|
||||
>>> 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_location = template.locations.new()
|
||||
>>> template_location.warehouse = warehouse_loc
|
||||
>>> template_location.location = child_loc
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product_location = product.locations.new()
|
||||
>>> product_location.warehouse = warehouse_loc
|
||||
>>> product_location.location = child_loc
|
||||
>>> assertEqual(product_location.template, template)
|
||||
>>> product.save()
|
||||
|
||||
Location is copied when copying the template::
|
||||
|
||||
>>> template_copy, = template.duplicate()
|
||||
>>> product_copy, = template_copy.products
|
||||
>>> len(template_copy.locations)
|
||||
2
|
||||
>>> len(product_copy.locations)
|
||||
1
|
||||
@@ -0,0 +1,122 @@
|
||||
================================
|
||||
Stock Product Locations Scenario
|
||||
================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.modules.currency.tests.tools import get_currency
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_product_location', create_company)
|
||||
|
||||
Get currency::
|
||||
|
||||
>>> currency = get_currency()
|
||||
|
||||
Create customer::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> supplier = Party(name='Suppier')
|
||||
>>> supplier.save()
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
|
||||
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
>>> output_loc, = Location.find([('code', '=', 'OUT')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> input_loc, = Location.find([('code', '=', 'IN')])
|
||||
|
||||
Create new location::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> child_loc = Location()
|
||||
>>> child_loc.name = 'Child Location'
|
||||
>>> child_loc.parent = storage_loc
|
||||
>>> child_loc.code = 'CHI'
|
||||
>>> child_loc.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.save()
|
||||
>>> product, = template.products
|
||||
>>> product_location = product.locations.new()
|
||||
>>> product_location.warehouse = warehouse_loc
|
||||
>>> product_location.location = child_loc
|
||||
>>> product.save()
|
||||
|
||||
Create Shipment in::
|
||||
|
||||
>>> Shipmentin = Model.get('stock.shipment.in')
|
||||
>>> shipment_in = Shipmentin()
|
||||
>>> shipment_in.planned_date = today
|
||||
>>> shipment_in.supplier = supplier
|
||||
>>> shipment_in.warehouse = warehouse_loc
|
||||
|
||||
Add one shipment line of product::
|
||||
|
||||
>>> move = shipment_in.incoming_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.unit = unit
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = supplier_loc
|
||||
>>> move.to_location = input_loc
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> shipment_in.save()
|
||||
|
||||
Test that to_location is child location on reception::
|
||||
|
||||
>>> shipment_in.click('receive')
|
||||
>>> move, = shipment_in.inventory_moves
|
||||
>>> assertEqual(move.to_location, child_loc)
|
||||
|
||||
Create return shipment out::
|
||||
|
||||
>>> Shipment_out_Return = Model.get('stock.shipment.out.return')
|
||||
>>> shipment_out_return = Shipment_out_Return()
|
||||
>>> shipment_out_return.customer = customer
|
||||
>>> shipment_out_return.save()
|
||||
|
||||
Add one shipment return line::
|
||||
|
||||
>>> move = shipment_out_return.incoming_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.unit = unit
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = customer_loc
|
||||
>>> move.to_location = input_loc
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> shipment_out_return.save()
|
||||
|
||||
Test that to_location is child location on reception::
|
||||
|
||||
>>> shipment_out_return.click('receive')
|
||||
>>> move, = shipment_out_return.inventory_moves
|
||||
>>> assertEqual(move.to_location, child_loc)
|
||||
@@ -0,0 +1,73 @@
|
||||
==========================================
|
||||
Stock Product Location Consumable Scenario
|
||||
==========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_product_location', create_company)
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ShipmentOut = Model.get('stock.shipment.out')
|
||||
>>> UoM = Model.get('product.uom')
|
||||
|
||||
Create customer::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create consumable location::
|
||||
|
||||
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
|
||||
|
||||
>>> consumable_loc = Location(name="Consumable")
|
||||
>>> consumable_loc.parent = warehouse_loc
|
||||
>>> consumable_loc.save()
|
||||
|
||||
Create consumable product::
|
||||
|
||||
>>> unit, = UoM.find([('name', '=', "Unit")])
|
||||
|
||||
>>> template = ProductTemplate(name="Consumable")
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.consumable = True
|
||||
>>> product_location = template.locations.new()
|
||||
>>> product_location.warehouse = warehouse_loc
|
||||
>>> product_location.location = consumable_loc
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Ship consumable product to customer::
|
||||
|
||||
>>> shipment = ShipmentOut(customer=customer)
|
||||
>>> move = shipment.outgoing_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = shipment.warehouse_output
|
||||
>>> move.to_location = shipment.customer_location
|
||||
>>> move.unit_price = Decimal(0)
|
||||
>>> move.currency = shipment.company.currency
|
||||
>>> shipment.click('wait')
|
||||
>>> shipment.state
|
||||
'waiting'
|
||||
|
||||
Assign the shipment::
|
||||
|
||||
>>> shipment_assign = shipment.click('assign_wizard')
|
||||
>>> shipment.state
|
||||
'assigned'
|
||||
|
||||
Check assigned from consumable location::
|
||||
|
||||
>>> move, = shipment.inventory_moves
|
||||
>>> assertEqual(move.from_location, consumable_loc)
|
||||
@@ -0,0 +1,141 @@
|
||||
===========================================
|
||||
Stock Product Locations Production Scenario
|
||||
===========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> _ = activate_modules(['stock_product_location', 'production'], create_company)
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> production_loc, = Location.find([('code', '=', 'PROD')])
|
||||
|
||||
Create new location::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> child_loc = Location()
|
||||
>>> child_loc.name = 'Child Location'
|
||||
>>> child_loc.parent = storage_loc
|
||||
>>> child_loc.code = 'CHI'
|
||||
>>> child_loc.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.producible = True
|
||||
>>> template.list_price = Decimal(30)
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product_location = product.locations.new()
|
||||
>>> product_location.warehouse = warehouse_loc
|
||||
>>> product_location.location = child_loc
|
||||
>>> product.save()
|
||||
|
||||
Create Components::
|
||||
|
||||
>>> template1 = ProductTemplate()
|
||||
>>> template1.name = 'component 1'
|
||||
>>> template1.default_uom = unit
|
||||
>>> template1.type = 'goods'
|
||||
>>> template1.list_price = Decimal(5)
|
||||
>>> template1.save()
|
||||
>>> component1, = template1.products
|
||||
|
||||
>>> meter, = ProductUom.find([('name', '=', 'Meter')])
|
||||
>>> centimeter, = ProductUom.find([('name', '=', 'Centimeter')])
|
||||
>>> template2 = ProductTemplate()
|
||||
>>> template2.name = 'component 2'
|
||||
>>> template2.default_uom = meter
|
||||
>>> template2.type = 'goods'
|
||||
>>> template2.list_price = Decimal(7)
|
||||
>>> template2.save()
|
||||
>>> component2, = template2.products
|
||||
|
||||
Create Bill of Material::
|
||||
|
||||
>>> BOM = Model.get('production.bom')
|
||||
>>> BOMInput = Model.get('production.bom.input')
|
||||
>>> BOMOutput = Model.get('production.bom.output')
|
||||
>>> bom = BOM(name='product')
|
||||
>>> input1 = BOMInput()
|
||||
>>> bom.inputs.append(input1)
|
||||
>>> input1.product = component1
|
||||
>>> input1.quantity = 5
|
||||
>>> input2 = BOMInput()
|
||||
>>> bom.inputs.append(input2)
|
||||
>>> input2.product = component2
|
||||
>>> input2.quantity = 150
|
||||
>>> input2.unit = centimeter
|
||||
>>> output = BOMOutput()
|
||||
>>> bom.outputs.append(output)
|
||||
>>> output.product = product
|
||||
>>> output.quantity = 1
|
||||
>>> bom.save()
|
||||
|
||||
>>> ProductBom = Model.get('product.product-production.bom')
|
||||
>>> product.boms.append(ProductBom(bom=bom))
|
||||
>>> product.save()
|
||||
|
||||
Create an Inventory::
|
||||
|
||||
>>> Inventory = Model.get('stock.inventory')
|
||||
>>> InventoryLine = Model.get('stock.inventory.line')
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location = storage_loc
|
||||
>>> inventory_line1 = InventoryLine()
|
||||
>>> inventory.lines.append(inventory_line1)
|
||||
>>> inventory_line1.product = component1
|
||||
>>> inventory_line1.quantity = 20
|
||||
>>> inventory_line2 = InventoryLine()
|
||||
>>> inventory.lines.append(inventory_line2)
|
||||
>>> inventory_line2.product = component2
|
||||
>>> inventory_line2.quantity = 6
|
||||
>>> inventory.click('confirm')
|
||||
>>> inventory.state
|
||||
'done'
|
||||
|
||||
Make a production::
|
||||
|
||||
>>> Production = Model.get('production')
|
||||
>>> production = Production()
|
||||
>>> production.planned_date = today
|
||||
>>> production.product = product
|
||||
>>> production.bom = bom
|
||||
>>> production.quantity = 2
|
||||
|
||||
Test storage location of the warehouse::
|
||||
|
||||
>> assertEqual(warehouse_loc.storage_location, storage_loc)
|
||||
|
||||
Test locations of the production inputs::
|
||||
|
||||
>>> for input_ in production.inputs:
|
||||
... assertEqual(input_.from_location, storage_loc)
|
||||
... assertEqual(input_.to_location, production_loc)
|
||||
|
||||
Test location of the production output::
|
||||
|
||||
>>> output, = production.outputs
|
||||
>>> assertEqual(output.from_location, production_loc)
|
||||
>>> assertEqual(output.to_location, child_loc)
|
||||
@@ -0,0 +1,121 @@
|
||||
=========================================
|
||||
Stock Product Locations Template Scenario
|
||||
=========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.modules.currency.tests.tools import get_currency
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
>>> today = dt.date.today()
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_product_location', create_company)
|
||||
|
||||
Get currency::
|
||||
|
||||
>>> currency = get_currency()
|
||||
|
||||
Create customer::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create supplier::
|
||||
|
||||
>>> supplier = Party(name='Suppier')
|
||||
>>> supplier.save()
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> warehouse_loc, = Location.find([('code', '=', 'WH')])
|
||||
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
>>> output_loc, = Location.find([('code', '=', 'OUT')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> input_loc, = Location.find([('code', '=', 'IN')])
|
||||
|
||||
Create new location::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> child_loc = Location()
|
||||
>>> child_loc.name = 'Child Location'
|
||||
>>> child_loc.parent = storage_loc
|
||||
>>> child_loc.code = 'CHI'
|
||||
>>> child_loc.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_location = template.locations.new()
|
||||
>>> template_location.warehouse = warehouse_loc
|
||||
>>> template_location.location = child_loc
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create Shipment in::
|
||||
|
||||
>>> Shipmentin = Model.get('stock.shipment.in')
|
||||
>>> shipment_in = Shipmentin()
|
||||
>>> shipment_in.planned_date = today
|
||||
>>> shipment_in.supplier = supplier
|
||||
>>> shipment_in.warehouse = warehouse_loc
|
||||
|
||||
Add one shipment line of product::
|
||||
|
||||
>>> move = shipment_in.incoming_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.unit = unit
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = supplier_loc
|
||||
>>> move.to_location = input_loc
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> shipment_in.save()
|
||||
|
||||
Test that to_location is child location on reception::
|
||||
|
||||
>>> shipment_in.click('receive')
|
||||
>>> move, = shipment_in.inventory_moves
|
||||
>>> assertEqual(move.to_location, child_loc)
|
||||
|
||||
Create return shipment out::
|
||||
|
||||
>>> Shipment_out_Return = Model.get('stock.shipment.out.return')
|
||||
>>> shipment_out_return = Shipment_out_Return()
|
||||
>>> shipment_out_return.customer = customer
|
||||
>>> shipment_out_return.save()
|
||||
|
||||
Add one shipment return line::
|
||||
|
||||
>>> move = shipment_out_return.incoming_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.unit = unit
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = customer_loc
|
||||
>>> move.to_location = input_loc
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> shipment_out_return.save()
|
||||
|
||||
Test that to_location is child location on reception::
|
||||
|
||||
>>> shipment_out_return.click('receive')
|
||||
>>> move, = shipment_out_return.inventory_moves
|
||||
>>> assertEqual(move.to_location, child_loc)
|
||||
13
modules/stock_product_location/tests/test_module.py
Normal file
13
modules/stock_product_location/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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 StockProductLocationTestCase(ModuleTestCase):
|
||||
'Test StockProductLocation module'
|
||||
module = 'stock_product_location'
|
||||
extras = ['production']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/stock_product_location/tests/test_scenario.py
Normal file
8
modules/stock_product_location/tests/test_scenario.py
Normal 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