first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View 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.

View File

@@ -0,0 +1,121 @@
============================
Stock Location Move Scenario
============================
Imports::
>>> import datetime as dt
>>> 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()
>>> tomorrow = today + dt.timedelta(1)
Activate modules::
>>> config = activate_modules('stock_location_move', create_company)
Get stock locations::
>>> Location = Model.get('stock.location')
>>> storage_loc, = Location.find([('code', '=', 'STO')])
>>> storage1 = Location(name="Storage 1", parent=storage_loc)
>>> storage1.save()
>>> storage2 = Location(name="Storage 2", parent=storage_loc)
>>> storage2.save()
>>> pallet = Location(name="Pallet", parent=storage1, movable=True)
>>> pallet.save()
Move pallet from storage1 to storage2::
>>> Shipment = Model.get('stock.shipment.internal')
>>> shipment = Shipment()
>>> shipment.from_location = storage1
>>> shipment.to_location = storage2
>>> shipment.locations.append(Location(pallet.id))
>>> shipment.click('wait')
>>> shipment.click('assign_try')
>>> shipment.state
'assigned'
>>> pallet.reload()
>>> assertEqual(pallet.assigned_by, shipment)
>>> assertEqual(pallet.parent, storage1)
>>> shipment.click('do')
>>> shipment.state
'done'
>>> pallet.reload()
>>> pallet.assigned_by
>>> assertEqual(pallet.parent, storage2)
Assign pallet from wrong location::
>>> shipment = Shipment()
>>> shipment.from_location = storage1
>>> shipment.to_location = storage2
>>> shipment.locations.append(Location(pallet.id))
>>> shipment.click('wait')
>>> shipment.click('assign_try')
Traceback (most recent call last):
...
DomainValidationError: ...
Concurrently move pallet::
>>> shipment1 = Shipment()
>>> shipment1.from_location = storage2
>>> shipment1.to_location = storage1
>>> shipment1.locations.append(Location(pallet.id))
>>> shipment1.click('wait')
>>> shipment2 = Shipment()
>>> shipment2.from_location = storage2
>>> shipment2.to_location = storage1
>>> shipment2.locations.append(Location(pallet.id))
>>> shipment2.click('wait')
>>> shipment1.click('assign_try')
>>> shipment1.state
'assigned'
>>> shipment2.click('assign_try')
Traceback (most recent call last):
...
AssignError: ...
>>> shipment1.click('do')
Add lead time between warehouses::
>>> warehouse1 = storage_loc.warehouse
>>> warehouse2, = warehouse1.duplicate()
>>> LeadTime = Model.get('stock.location.lead_time')
>>> lead_time = LeadTime()
>>> lead_time.warehouse_from = warehouse1
>>> lead_time.warehouse_to = warehouse2
>>> lead_time.lead_time = dt.timedelta(1)
>>> lead_time.save()
Move pallet from storage1 to storage2 with lead_time::
>>> Shipment = Model.get('stock.shipment.internal')
>>> shipment = Shipment()
>>> shipment.planned_date = tomorrow
>>> shipment.from_location = warehouse1.storage_location
>>> shipment.to_location = warehouse2.storage_location
>>> shipment.locations.append(Location(pallet.id))
>>> shipment.click('wait')
>>> shipment.click('assign_try')
>>> shipment.click('pack')
>>> shipment.click('ship')
>>> shipment.state
'shipped'
>>> pallet.reload()
>>> assertEqual(pallet.parent, shipment.transit_location)
>>> shipment.click('do')
>>> pallet.reload()
>>> assertEqual(pallet.parent, warehouse2.storage_location)

View File

@@ -0,0 +1,160 @@
==================================
Stock Location Move Empty Scenario
==================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules
>>> today = dt.date.today()
>>> yesterday = today - dt.timedelta(1)
>>> tomorrow = today + dt.timedelta(1)
Activate modules::
>>> config = activate_modules('stock_location_move', create_company)
Get company::
>>> company = get_company()
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.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')])
>>> storage1 = Location(name="Storage 1", parent=storage_loc)
>>> storage1.save()
>>> pallet1 = Location(name="Pallet 1", parent=storage_loc, movable=True)
>>> pallet1.save()
>>> pallet2 = Location(name="Pallet 2", parent=storage_loc, movable=True)
>>> pallet2.save()
>>> pallet3 = Location(name="Pallet 3", parent=storage_loc, movable=True)
>>> pallet3.save()
Create products::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(0)
>>> template.save()
>>> product1 = Product()
>>> product1.template = template
>>> product1.save()
>>> product2 = Product()
>>> product2.template = template
>>> product2.save()
>>> product3 = Product()
>>> product3.template = template
>>> product3.save()
Fill storage locations::
>>> StockMove = Model.get('stock.move')
>>> incoming_move = StockMove()
>>> incoming_move.product = product1
>>> incoming_move.quantity = 1
>>> incoming_move.unit_price = Decimal('0')
>>> incoming_move.currency = company.currency
>>> incoming_move.from_location = supplier_loc
>>> incoming_move.to_location = storage1
>>> incoming_move.effective_date = yesterday
>>> incoming_move.click('do')
>>> incoming_move = StockMove()
>>> incoming_move.product = product2
>>> incoming_move.quantity = 1
>>> incoming_move.unit_price = Decimal('0')
>>> incoming_move.currency = company.currency
>>> incoming_move.from_location = supplier_loc
>>> incoming_move.to_location = pallet1
>>> incoming_move.effective_date = yesterday
>>> incoming_move.click('do')
>>> incoming_move = StockMove()
>>> incoming_move.product = product3
>>> incoming_move.quantity = 2
>>> incoming_move.unit_price = Decimal('0')
>>> incoming_move.currency = company.currency
>>> incoming_move.from_location = supplier_loc
>>> incoming_move.to_location = pallet2
>>> incoming_move.effective_date = yesterday
>>> incoming_move.click('do')
Ship 1 product from the locations::
>>> ShipmentOut = Model.get('stock.shipment.out')
>>> shipment = ShipmentOut()
>>> shipment.customer = customer
>>> shipment.warehouse = warehouse_loc
>>> move = shipment.outgoing_moves.new()
>>> move.product = product1
>>> move.quantity = 1
>>> move.unit_price = Decimal('0')
>>> move.currency = company.currency
>>> move.from_location = output_loc
>>> move.to_location = customer_loc
>>> move = shipment.outgoing_moves.new()
>>> move.product = product2
>>> move.quantity = 1
>>> move.unit_price = Decimal('0')
>>> move.currency = company.currency
>>> move.from_location = output_loc
>>> move.to_location = customer_loc
>>> move = shipment.outgoing_moves.new()
>>> move.product = product3
>>> move.quantity = 1
>>> move.unit_price = Decimal('0')
>>> move.currency = company.currency
>>> move.from_location = output_loc
>>> move.to_location = customer_loc
>>> shipment.click('wait')
>>> shipment.click('assign_try')
>>> shipment.click('pick')
>>> shipment.click('pack')
>>> shipment.click('do')
Check empty non movable location are still active::
>>> storage1.reload()
>>> bool(storage1.active)
True
Check empty location are deactivated::
>>> pallet1.reload()
>>> bool(pallet1.active)
False
Check non empty location are still active::
>>> pallet2.reload()
>>> bool(pallet2.active)
True
Check non changed empty location are still active::
>>> pallet3.reload()
>>> bool(pallet3.active)
True

View File

@@ -0,0 +1,108 @@
==========================
Stock Location Move Supply
==========================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model, Wizard
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
>>> today = dt.date.today()
Activate modules::
>>> config = activate_modules(
... ['stock_location_move', 'stock_supply'],
... create_company)
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.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')])
>>> provisioning_loc = Location(
... name="Provisioning Location", parent=warehouse_loc)
>>> provisioning_loc.save()
>>> pallet = Location(name="Pallet", parent=provisioning_loc, movable=True)
>>> pallet.save()
Create products::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(0)
>>> template.save()
>>> product = Product()
>>> product.template = template
>>> product.save()
Create internal order point::
>>> OrderPoint = Model.get('stock.order_point')
>>> order_point = OrderPoint()
>>> order_point.product = product
>>> order_point.location = storage_loc
>>> order_point.provisioning_location = provisioning_loc
>>> order_point.type = 'internal'
>>> order_point.min_quantity = 2
>>> order_point.target_quantity = 2
>>> order_point.save()
Fill pallet::
>>> Inventory = Model.get('stock.inventory')
>>> inventory = Inventory()
>>> inventory.location = pallet
>>> inventory_line = inventory.lines.new(product=product)
>>> inventory_line.quantity = 1
>>> inventory.click('confirm')
Plan moving pallet::
>>> ShipmentInternal = Model.get('stock.shipment.internal')
>>> shipment = ShipmentInternal()
>>> shipment.planned_date = today
>>> shipment.from_location = provisioning_loc
>>> shipment.to_location = storage_loc
>>> shipment.locations.append(Location(pallet.id))
>>> shipment.save()
Execute internal supply::
>>> Wizard('stock.supply').execute('create_')
Only 1 product is requested::
>>> shipment, = ShipmentInternal.find([
... ('id', '!=', shipment.id),
... ])
>>> shipment.state
'request'
>>> move, = shipment.moves
>>> move.quantity
1.0
Pallet did not moved::
>>> pallet.reload()
>>> pallet.parent.name
'Provisioning Location'

View 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 StockLocationMoveTestCase(ModuleTestCase):
'Test Stock Location Move module'
module = 'stock_location_move'
extras = ['stock_supply']
del ModuleTestCase

View 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)