Add scenario to test the modification of stock lot without moves

This commit is contained in:
Cédric Krier
2026-07-21 19:14:58 +02:00
parent a062121249
commit 55b26ce2bd
2 changed files with 135 additions and 0 deletions
@@ -0,0 +1,61 @@
=================================
Stock Lot Modify No Move Scenario
=================================
Imports::
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('stock_lot', create_company)
>>> Location = Model.get('stock.location')
>>> Lot = Model.get('stock.lot')
>>> Move = Model.get('stock.move')
>>> ProductTemplate = Model.get('product.template')
>>> UoM = Model.get('product.uom')
Create products::
>>> unit, = UoM.find([('name', '=', "Unit")])
>>> template1 = ProductTemplate(
... name="Product 1", type='goods', default_uom=unit)
>>> template1.save()
>>> product1, = template1.products
>>> template2 = ProductTemplate(
... name="Product 2", type='goods', default_uom=unit)
>>> template2.save()
>>> product2, = template2.products
Create a lot::
>>> lot = Lot(number="1", product=product2)
>>> lot.save()
Modify the product of the lot without move::
>>> lot.product = product1
>>> lot.save()
Create a move with the lot::
>>> lost_found, = Location.find([('type', '=', 'lost_found')])
>>> storage, = Location.find([('code', '=', 'STO')])
>>> move = Move(
... product=product1, lot=lot, quantity=1,
... from_location=lost_found, to_location=storage)
>>> move.save()
Try to modify the product of the lot with move::
>>> lot.product = product2
>>> lot.save()
Traceback (most recent call last):
...
AccessError: ...
@@ -0,0 +1,74 @@
=================================
Stock Lot Modify No Move Scenario
=================================
Imports::
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('stock_lot_unit', create_company)
>>> Location = Model.get('stock.location')
>>> Lot = Model.get('stock.lot')
>>> Move = Model.get('stock.move')
>>> ProductTemplate = Model.get('product.template')
>>> UoM = Model.get('product.uom')
Create product::
>>> unit1, = UoM.find([('name', '=', "Unit")])
>>> unit2, = unit1.duplicate()
>>> template = ProductTemplate(
... name="Product", type='goods', default_uom=unit1)
>>> template.save()
>>> product, = template.products
Create a lot::
>>> lot = Lot(
... number="1", product=product,
... unit=unit2, unit_quantity=3)
>>> lot.save()
Create a move with the lot::
>>> lost_found, = Location.find([('type', '=', 'lost_found')])
>>> storage, = Location.find([('code', '=', 'STO')])
>>> move = Move(
... product=product, lot=lot, quantity=5,
... from_location=lost_found, to_location=storage)
>>> move.save()
Modify the units of the lot without move done::
>>> lot.unit = unit1
>>> lot.unit_quantity = 5
>>> lot.save()
Complete the move::
>>> move.click('do')
>>> move.state
'done'
Try to modify the units of the lot with move done::
>>> lot.unit = unit2
>>> lot.save()
Traceback (most recent call last):
...
AccessError: ...
>>> lot.reload()
>>> lot.unit_quantity = 3
>>> lot.save()
Traceback (most recent call last):
...
AccessError: ...