details:   https://code.tryton.org/tryton/commit/be33bba562b1
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue Jul 21 19:14:58 2026 +0200
description:
        Add scenario to test the modification of stock lot without moves
diffstat:

 modules/stock_lot/tests/scenario_stock_lot_modify_no_move.rst      |  61 
++++++++
 modules/stock_lot_unit/tests/scenario_stock_lot_modify_no_move.rst |  74 
++++++++++
 2 files changed, 135 insertions(+), 0 deletions(-)

diffs (143 lines):

diff -r 3cb38ab5ba4a -r be33bba562b1 
modules/stock_lot/tests/scenario_stock_lot_modify_no_move.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/stock_lot/tests/scenario_stock_lot_modify_no_move.rst     Tue Jul 
21 19:14:58 2026 +0200
@@ -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: ...
diff -r 3cb38ab5ba4a -r be33bba562b1 
modules/stock_lot_unit/tests/scenario_stock_lot_modify_no_move.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/stock_lot_unit/tests/scenario_stock_lot_modify_no_move.rst        
Tue Jul 21 19:14:58 2026 +0200
@@ -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: ...
+

Reply via email to