Add test scenario to inventory count with lot

This commit is contained in:
Cédric Krier committed 2024-06-30 19:16:48 +02:00
1 parent 1ab12f3e87
commit a7d4ae446a
1 file changed
+79
@@ -0,0 +1,79 @@
==================================
Stock Lot Inventory Count Scenario
==================================
Imports::
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, assertEqual
Activate modules::
>>> config = activate_modules('stock_lot')
>>> 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')
Create company::
>>> _ = create_company()
>>> company = get_company()
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)
>>> 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 = product
>>> count.execute('quantity')
Traceback (most recent call last):
...
RequiredValidationError: ...
>>> 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