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,113 @@
=============================
Stock Shipping Point 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_shipping_point', create_company)
>>> Country = Model.get('country.country')
>>> Party = Model.get('party.party')
>>> Product = Model.get('product.product')
>>> ProductCategory = Model.get('product.category')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Shipment = Model.get('stock.shipment.out')
>>> ShippingPoint = Model.get('stock.shipping.point')
>>> ShippingPointSelection = Model.get('stock.shipping.point.selection')
Get currency::
>>> currency = get_currency()
Create countries::
>>> belgium = Country(code="BE", name="Belgium")
>>> belgium.save()
>>> france = Country(code="FR", name="France")
>>> france.save()
Create a customer::
>>> customer = Party(name='Customer')
>>> address, = customer.addresses
>>> address.country = belgium
>>> customer.save()
Create product categories::
>>> category1 = ProductCategory(name="Category 1")
>>> category1.save()
>>> category1_child = ProductCategory(name="Child 1", parent=category1)
>>> category1_child.save()
>>> category2 = ProductCategory(name="Category 2")
>>> category2.save()
Create a product::
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.categories.append(category1_child)
>>> template.save()
>>> product, = template.products
Create some shipping point::
>>> shipping_point1 = ShippingPoint(name="Point 1")
>>> shipping_point1.save()
>>> shipping_point2 = ShippingPoint(name="Point 2")
>>> shipping_point2.save()
Setup selections::
>>> ShippingPointSelection(
... shipping_point=shipping_point1,
... delivery_country=belgium).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point2,
... delivery_country=france).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point1,
... contains_product_categories=[ProductCategory(category1.id)]).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point2,
... contains_product_categories=[ProductCategory(category2.id)]).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point1,
... delivery_country=belgium,
... contains_product_categories=[ProductCategory(category1.id)]).save()
Create a customer shipment::
>>> shipment = Shipment()
>>> shipment.customer = customer
>>> move = shipment.outgoing_moves.new()
>>> move.product = product
>>> move.quantity = 1
>>> move.from_location = shipment.warehouse_output
>>> move.to_location = shipment.customer_location
>>> move.unit_price = Decimal('42.0000')
>>> move.currency = currency
>>> shipment.save()
>>> shipment.state
'draft'
>>> shipment.shipping_point
Wait the customer shipment::
>>> shipment.click('wait')
>>> shipment.state
'waiting'
>>> assertEqual(shipment.shipping_point, shipping_point1)

View File

@@ -0,0 +1,116 @@
=========================================================
Stock Shipping Point with Product Classification 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_shipping_point', 'product_classification_taxonomic'],
... create_company)
>>> Party = Model.get('party.party')
>>> Product = Model.get('product.product')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Shipment = Model.get('stock.shipment.out')
>>> ShippingPoint = Model.get('stock.shipping.point')
>>> ShippingPointSelection = Model.get('stock.shipping.point.selection')
>>> Taxon = Model.get('product.taxon')
>>> Cultivar = Model.get('product.cultivar')
Get currency::
>>> currency = get_currency()
Create a customer::
>>> customer = Party(name='Customer')
>>> customer.save()
Create classifications::
>>> taxon = Taxon(name="Taxon")
>>> taxon.save()
>>> taxon_child = Taxon(name="Taxon Child", parent=taxon)
>>> taxon_child.save()
>>> cultivar = Cultivar(name="Cultivar", taxon=taxon_child)
>>> cultivar.save()
Create a product::
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.save()
>>> product, = template.products
Create some shipping point::
>>> shipping_point1 = ShippingPoint(name="Point 1")
>>> shipping_point1.save()
>>> shipping_point2 = ShippingPoint(name="Point 2")
>>> shipping_point2.save()
Setup selections::
>>> ShippingPointSelection(
... shipping_point=shipping_point2,
... contains_product_classification=taxon).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point1,
... contains_product_classification=cultivar).save()
Create a customer shipment::
>>> shipment = Shipment()
>>> shipment.customer = customer
>>> move = shipment.outgoing_moves.new()
>>> move.product = product
>>> move.quantity = 1
>>> move.from_location = shipment.warehouse_output
>>> move.to_location = shipment.customer_location
>>> move.unit_price = Decimal('42.0000')
>>> move.currency = currency
>>> shipment.save()
>>> shipment.state
'draft'
>>> shipment.shipping_point
Wait the customer shipment with taxon::
>>> template.classification = taxon_child
>>> template.save()
>>> shipment.click('wait')
>>> shipment.state
'waiting'
>>> assertEqual(shipment.shipping_point, shipping_point2)
Reset to draft::
>>> shipment.click('draft')
>>> shipment.state
'draft'
Wait the customer shipment with cultivar::
>>> template.classification = cultivar
>>> template.save()
>>> shipment.click('wait')
>>> shipment.state
'waiting'
>>> assertEqual(shipment.shipping_point, shipping_point1)

View File

@@ -0,0 +1,95 @@
========================================================
Stock Shipping Point with Shipment Measurements 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_shipping_point', 'stock_shipment_measurements'],
... create_company)
>>> Party = Model.get('party.party')
>>> Product = Model.get('product.product')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Shipment = Model.get('stock.shipment.out')
>>> ShippingPoint = Model.get('stock.shipping.point')
>>> ShippingPointSelection = Model.get('stock.shipping.point.selection')
Get currency::
>>> currency = get_currency()
Create a customer::
>>> customer = Party(name='Customer')
>>> customer.save()
Create a product::
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> kg, = ProductUom.find([('name', '=', 'Kilogram')])
>>> gr, = ProductUom.find([('name', '=', 'Gram')])
>>> liter, = ProductUom.find([('name', '=', 'Liter')])
>>> cm3, = ProductUom.find([('name', '=', 'Cubic centimeter')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.weight = 500
>>> template.weight_uom = gr
>>> template.volume = 100
>>> template.volume_uom = cm3
>>> template.save()
>>> product, = template.products
Create some shipping point::
>>> shipping_point1 = ShippingPoint(name="Point 1")
>>> shipping_point1.save()
>>> shipping_point2 = ShippingPoint(name="Point 2")
>>> shipping_point2.save()
Setup selections::
>>> ShippingPointSelection(
... shipping_point=shipping_point2,
... min_weight=1, max_weight=10, weight_uom=kg,
... min_volume=1, max_volume=100, volume_uom=liter).save()
>>> ShippingPointSelection(
... shipping_point=shipping_point1,
... min_weight=.2, max_weight=1, weight_uom=kg,
... min_volume=.01, max_volume=1, volume_uom=liter).save()
Create a customer shipment::
>>> shipment = Shipment()
>>> shipment.customer = customer
>>> move = shipment.outgoing_moves.new()
>>> move.product = product
>>> move.quantity = 1
>>> move.from_location = shipment.warehouse_output
>>> move.to_location = shipment.customer_location
>>> move.unit_price = Decimal('42.0000')
>>> move.currency = currency
>>> shipment.save()
>>> shipment.state
'draft'
>>> shipment.shipping_point
Wait the customer shipment::
>>> shipment.click('wait')
>>> shipment.state
'waiting'
>>> assertEqual(shipment.shipping_point, shipping_point1)

View File

@@ -0,0 +1,12 @@
# 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 StockShippingPointTestCase(ModuleTestCase):
"Test Stock Shipping Point module"
module = 'stock_shipping_point'
extras = ['product_classification', 'stock_shipment_measurements']
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)