first commit
This commit is contained in:
2
modules/stock_lot_unit/tests/__init__.py
Normal file
2
modules/stock_lot_unit/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,68 @@
|
||||
=======================================
|
||||
Stock Lot Unit Inventory Count Scenario
|
||||
=======================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> 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_lot_unit', create_company)
|
||||
>>> config.skip_warning = True
|
||||
|
||||
>>> Inventory = Model.get('stock.inventory')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> Lot = Model.get('stock.lot')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
|
||||
Get stock location::
|
||||
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
|
||||
Create product and lot::
|
||||
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.lot_required = ['storage']
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> lot = Lot(number="0001", product=product, unit=unit)
|
||||
>>> lot.save()
|
||||
|
||||
Create an inventory::
|
||||
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location = storage_loc
|
||||
>>> inventory.empty_quantity = 'keep'
|
||||
>>> inventory.save()
|
||||
|
||||
Count inventory::
|
||||
|
||||
>>> count = inventory.click('do_count')
|
||||
|
||||
>>> count.form.search = lot
|
||||
>>> count.execute('quantity')
|
||||
>>> assertEqual(count.form.product, product)
|
||||
>>> assertEqual(count.form.lot, lot)
|
||||
>>> count.form.quantity
|
||||
1.0
|
||||
>>> count.form.total_quantity
|
||||
1.0
|
||||
>>> count.execute('add')
|
||||
>>> count.execute('end')
|
||||
|
||||
Check inventory::
|
||||
|
||||
>>> line, = inventory.lines
|
||||
>>> assertEqual(line.product, product)
|
||||
>>> assertEqual(line.lot, lot)
|
||||
>>> line.quantity
|
||||
1.0
|
||||
184
modules/stock_lot_unit/tests/scenario_stock_lot_unit.rst
Normal file
184
modules/stock_lot_unit/tests/scenario_stock_lot_unit.rst
Normal file
@@ -0,0 +1,184 @@
|
||||
=======================
|
||||
Stock Lot Unit Scenario
|
||||
=======================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> 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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_lot_unit', 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='Supplier')
|
||||
>>> supplier.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.lot_uom = unit
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('8')
|
||||
>>> product.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')])
|
||||
>>> input_loc, = Location.find([('code', '=', 'IN')])
|
||||
>>> output_loc, = Location.find([('code', '=', 'OUT')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
|
||||
Create an incoming shipment without lot::
|
||||
|
||||
>>> ShipmentIn = Model.get('stock.shipment.in')
|
||||
>>> shipment = ShipmentIn()
|
||||
>>> shipment.supplier = supplier
|
||||
>>> move1 = shipment.incoming_moves.new()
|
||||
>>> move1.product = product
|
||||
>>> move1.quantity = 60
|
||||
>>> move1.unit_price = Decimal('8')
|
||||
>>> move1.currency = currency
|
||||
>>> move1.from_location = supplier_loc
|
||||
>>> move1.to_location = input_loc
|
||||
>>> move2 = shipment.incoming_moves.new()
|
||||
>>> move2.product = product
|
||||
>>> move2.quantity = 40
|
||||
>>> move2.unit_price = Decimal('8')
|
||||
>>> move2.currency = currency
|
||||
>>> move2.from_location = supplier_loc
|
||||
>>> move2.to_location = input_loc
|
||||
>>> shipment.click('receive')
|
||||
>>> shipment.click('do')
|
||||
|
||||
Let's ship a product with a lot::
|
||||
|
||||
>>> Lot = Model.get('stock.lot')
|
||||
>>> lot = Lot(number='00001', product=product)
|
||||
>>> assertEqual(lot.unit, unit)
|
||||
>>> lot.unit_quantity
|
||||
1.0
|
||||
>>> lot.save()
|
||||
|
||||
>>> ShipmentOut = Model.get('stock.shipment.out')
|
||||
>>> shipment = ShipmentOut()
|
||||
>>> shipment.customer = customer
|
||||
>>> move = shipment.outgoing_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 1
|
||||
>>> move.unit_price = Decimal('20')
|
||||
>>> move.currency = currency
|
||||
>>> move.from_location = output_loc
|
||||
>>> move.to_location = customer_loc
|
||||
>>> shipment.click('wait')
|
||||
>>> shipment.click('assign_try')
|
||||
>>> move.lot = lot
|
||||
>>> shipment.click('pick')
|
||||
>>> shipment.click('pack')
|
||||
>>> shipment.click('do')
|
||||
|
||||
Let's ship now two times the same lot::
|
||||
|
||||
>>> lot = Lot(number='00002', product=product)
|
||||
>>> lot.save()
|
||||
|
||||
>>> shipment = ShipmentOut()
|
||||
>>> shipment.customer = customer
|
||||
>>> move1 = shipment.outgoing_moves.new()
|
||||
>>> move1.product = product
|
||||
>>> move1.quantity = 1
|
||||
>>> move1.unit_price = Decimal('20')
|
||||
>>> move1.currency = currency
|
||||
>>> move1.from_location = output_loc
|
||||
>>> move1.to_location = customer_loc
|
||||
>>> move2 = shipment.outgoing_moves.new()
|
||||
>>> move2.product = product
|
||||
>>> move2.quantity = 1
|
||||
>>> move2.unit_price = Decimal('20')
|
||||
>>> move2.currency = currency
|
||||
>>> move2.from_location = output_loc
|
||||
>>> move2.to_location = customer_loc
|
||||
>>> shipment.click('wait')
|
||||
>>> shipment.click('assign_try')
|
||||
>>> move1, move2 = shipment.inventory_moves
|
||||
>>> move1.lot = lot
|
||||
>>> move2.lot = lot
|
||||
>>> shipment.save()
|
||||
>>> shipment.click('pick')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
LotUnitQuantityError: ...
|
||||
|
||||
Now let's ship one move with a quantity bigger than lot unit quantity::
|
||||
|
||||
>>> lot = Lot(number='00003', product=product)
|
||||
>>> lot.unit_quantity = 3
|
||||
>>> lot.save()
|
||||
|
||||
>>> shipment = ShipmentOut()
|
||||
>>> shipment.customer = customer
|
||||
>>> move = shipment.outgoing_moves.new()
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 4
|
||||
>>> move.unit_price = Decimal('20')
|
||||
>>> move.currency = currency
|
||||
>>> move.from_location = output_loc
|
||||
>>> move.to_location = customer_loc
|
||||
>>> shipment.click('wait')
|
||||
>>> shipment.click('assign_try')
|
||||
>>> move, = shipment.inventory_moves
|
||||
>>> move.lot = lot
|
||||
>>> shipment.click('pick')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
LotUnitQuantityError: ...
|
||||
|
||||
Make an inventory::
|
||||
|
||||
>>> lot = Lot(number='00004', product=product)
|
||||
>>> lot.unit_quantity = 2
|
||||
>>> lot.save()
|
||||
|
||||
>>> Inventory = Model.get('stock.inventory')
|
||||
>>> inventory = Inventory()
|
||||
>>> inventory.location = storage_loc
|
||||
>>> line = inventory.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.lot = lot
|
||||
>>> line.quantity = 3
|
||||
>>> inventory.save()
|
||||
>>> inventory.click('confirm')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
LotUnitQuantityError: ...
|
||||
|
||||
>>> line, = inventory.lines
|
||||
>>> line.quantity = 2
|
||||
>>> inventory.click('confirm')
|
||||
@@ -0,0 +1,70 @@
|
||||
================================
|
||||
Stock Lot Unit Move Add Scenario
|
||||
================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> 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
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_lot_unit', create_company)
|
||||
|
||||
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
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
|
||||
Create a move::
|
||||
|
||||
>>> Move = Model.get('stock.move')
|
||||
>>> move = Move()
|
||||
>>> move.from_location = storage_loc
|
||||
>>> move.to_location = customer_loc
|
||||
>>> move.product = product
|
||||
>>> move.quantity = 5
|
||||
>>> move.unit_price = Decimal('20')
|
||||
>>> move.currency = get_currency()
|
||||
>>> move.save()
|
||||
|
||||
Create a lot::
|
||||
|
||||
>>> Lot = Model.get('stock.lot')
|
||||
>>> lot = Lot(number='01', product=product)
|
||||
>>> lot.unit = unit
|
||||
>>> lot.unit_quantity = 1
|
||||
>>> lot.save()
|
||||
|
||||
Add a lot::
|
||||
|
||||
>>> add_lots = move.click('add_lots_wizard')
|
||||
>>> lot = add_lots.form.lots.new()
|
||||
>>> lot.quantity
|
||||
5.0
|
||||
>>> lot.product = product # proteus does not set reverse domain
|
||||
>>> lot.number = '01'
|
||||
>>> assertEqual(lot.unit, unit)
|
||||
>>> lot.unit_quantity
|
||||
1.0
|
||||
>>> lot.quantity
|
||||
1.0
|
||||
13
modules/stock_lot_unit/tests/test_module.py
Normal file
13
modules/stock_lot_unit/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 StockLotUnitTestCase(ModuleTestCase):
|
||||
'Test Stock Lot Unit module'
|
||||
module = 'stock_lot_unit'
|
||||
extras = ['production']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/stock_lot_unit/tests/test_scenario.py
Normal file
8
modules/stock_lot_unit/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