diff --git a/modules/stock_package/CHANGELOG b/modules/stock_package/CHANGELOG
index 8f8a45f9a0..f4d42e86cd 100644
--- a/modules/stock_package/CHANGELOG
+++ b/modules/stock_package/CHANGELOG
@@ -1,3 +1,4 @@
+* Remove packaging prefix from dimensions
* Remove support for Python 3.7
* Add support for Python 3.11
diff --git a/modules/stock_package/stock.py b/modules/stock_package/stock.py
index c50533a003..4dd9fc476d 100644
--- a/modules/stock_package/stock.py
+++ b/modules/stock_package/stock.py
@@ -80,54 +80,49 @@ class ConfigurationSequence(metaclass=PoolMeta):
class MeasurementsMixin:
__slots__ = ()
- packaging_length = fields.Float(
- "Packaging Length", digits='packaging_length_uom',
+ length = fields.Float(
+ "Length", digits='length_uom',
help="The length of the package.")
- packaging_length_uom = fields.Many2One(
- 'product.uom', "Packaging Length UOM",
+ length_uom = fields.Many2One(
+ 'product.uom', "Length UOM",
domain=[('category', '=', Id('product', 'uom_cat_length'))],
states={
- 'required': Bool(Eval('packaging_length')),
- },
- depends=['packaging_length'])
- packaging_height = fields.Float(
- "Packaging Height", digits='packaging_height_uom',
+ 'required': Bool(Eval('length')),
+ })
+ height = fields.Float(
+ "Height", digits='height_uom',
help="The height of the package.")
- packaging_height_uom = fields.Many2One(
- 'product.uom', "Packaging Height UOM",
+ height_uom = fields.Many2One(
+ 'product.uom', "Height UOM",
domain=[('category', '=', Id('product', 'uom_cat_length'))],
states={
- 'required': Bool(Eval('packaging_height')),
- },
- depends=['packaging_height'])
- packaging_width = fields.Float(
- "Packaging Width", digits='packaging_width_uom',
+ 'required': Bool(Eval('height')),
+ })
+ width = fields.Float(
+ "Width", digits='width_uom',
help="The width of the package.")
- packaging_width_uom = fields.Many2One(
- 'product.uom', "Packaging Width UOM",
+ width_uom = fields.Many2One(
+ 'product.uom', "Width UOM",
domain=[('category', '=', Id('product', 'uom_cat_length'))],
states={
- 'required': Bool(Eval('packaging_width')),
- },
- depends=['packaging_width'])
+ 'required': Bool(Eval('width')),
+ })
packaging_volume = fields.Float(
"Packaging Volume", digits='packaging_volume_uom',
states={
'readonly': (
- Bool(Eval('packaging_length'))
- & Bool(Eval('packaging_height'))
- & Bool(Eval('packaging_width'))),
+ Bool(Eval('length'))
+ & Bool(Eval('height'))
+ & Bool(Eval('width'))),
},
- depends=['packaging_length', 'packaging_height', 'packaging_width'],
help="The volume of the package.")
packaging_volume_uom = fields.Many2One(
'product.uom', "Packaging Volume UOM",
domain=[('category', '=', Id('product', 'uom_cat_volume'))],
states={
'required': Bool(Eval('packaging_volume')),
- },
- depends=['packaging_volume'])
+ })
packaging_weight = fields.Float(
"Packaging Weight", digits='packaging_weight_uom',
@@ -141,22 +136,22 @@ class MeasurementsMixin:
@fields.depends(
'packaging_volume', 'packaging_volume_uom',
- 'packaging_length', 'packaging_length_uom',
- 'packaging_height', 'packaging_height_uom',
- 'packaging_width', 'packaging_width_uom')
+ 'length', 'length_uom',
+ 'height', 'height_uom',
+ 'width', 'width_uom')
def on_change_with_packaging_volume(self):
pool = Pool()
ModelData = pool.get('ir.model.data')
Uom = pool.get('product.uom')
if not all([self.packaging_volume_uom,
- self.packaging_length, self.packaging_length_uom,
- self.packaging_height, self.packaging_height_uom,
- self.packaging_width, self.packaging_width_uom]):
+ self.length, self.length_uom,
+ self.height, self.height_uom,
+ self.width, self.width_uom]):
if all([
- self.packaging_length,
- self.packaging_height,
- self.packaging_width]):
+ self.length,
+ self.height,
+ self.width]):
return
return self.packaging_volume
@@ -164,14 +159,11 @@ class MeasurementsMixin:
cubic_meter = Uom(ModelData.get_id('product', 'uom_cubic_meter'))
length = Uom.compute_qty(
- self.packaging_length_uom, self.packaging_length, meter,
- round=False)
+ self.length_uom, self.length, meter, round=False)
height = Uom.compute_qty(
- self.packaging_height_uom, self.packaging_height, meter,
- round=False)
+ self.height_uom, self.height, meter, round=False)
width = Uom.compute_qty(
- self.packaging_width_uom, self.packaging_width, meter,
- round=False)
+ self.width_uom, self.width, meter, round=False)
return Uom.compute_qty(
cubic_meter, length * height * width, self.packaging_volume_uom)
diff --git a/modules/stock_package/tests/scenario_stock_package.rst b/modules/stock_package/tests/scenario_stock_package.rst
index d74425e44d..75b9f54c7e 100644
--- a/modules/stock_package/tests/scenario_stock_package.rst
+++ b/modules/stock_package/tests/scenario_stock_package.rst
@@ -86,22 +86,22 @@ Package products::
>>> PackageType = Model.get('stock.package.type')
>>> box = PackageType(name='box')
- >>> box.packaging_length = 80
- >>> box.packaging_length_uom, = ProductUom.find([('name', '=', "Centimeter")])
- >>> box.packaging_width = 1
- >>> box.packaging_width_uom, = ProductUom.find([('name', '=', "Meter")])
- >>> box.packaging_height_uom = box.packaging_length_uom
+ >>> box.length = 80
+ >>> box.length_uom, = ProductUom.find([('name', '=', "Centimeter")])
+ >>> box.width = 1
+ >>> box.width_uom, = ProductUom.find([('name', '=', "Meter")])
+ >>> box.height_uom = box.length_uom
>>> box.packaging_volume
>>> box.packaging_volume_uom, = ProductUom.find([('name', '=', "Cubic meter")])
>>> box.save()
>>> package1 = shipment_out.packages.new(type=box)
- >>> package1.packaging_length
+ >>> package1.length
80.0
- >>> package1.packaging_height = 50
+ >>> package1.height = 50
>>> package1.packaging_volume
0.4
>>> package_child = package1.children.new(shipment=shipment_out, type=box)
- >>> package_child.packaging_height = 100
+ >>> package_child.height = 100
>>> moves = package_child.moves.find()
>>> len(moves)
2
@@ -112,7 +112,7 @@ Package products::
...
PackageValidationError: ...
- >>> package1.packaging_height = 120
+ >>> package1.height = 120
>>> package1.packaging_volume
0.96
diff --git a/modules/stock_package/view/package_form.xml b/modules/stock_package/view/package_form.xml
index f149fc19d9..9bf54e9df4 100644
--- a/modules/stock_package/view/package_form.xml
+++ b/modules/stock_package/view/package_form.xml
@@ -20,17 +20,17 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/modules/stock_package/view/package_type_form.xml b/modules/stock_package/view/package_type_form.xml
index 4b786518f2..408ecd017b 100644
--- a/modules/stock_package/view/package_type_form.xml
+++ b/modules/stock_package/view/package_type_form.xml
@@ -8,17 +8,17 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/modules/stock_package_shipping/CHANGELOG b/modules/stock_package_shipping/CHANGELOG
index d798221345..15bf4a8cd6 100644
--- a/modules/stock_package_shipping/CHANGELOG
+++ b/modules/stock_package_shipping/CHANGELOG
@@ -1,3 +1,4 @@
+* Move dimensions definition to stock_package module
* Remove support for Python 3.7
* Add support for Python 3.11
diff --git a/modules/stock_package_shipping/__init__.py b/modules/stock_package_shipping/__init__.py
index 93565afe2c..eeecf0436f 100644
--- a/modules/stock_package_shipping/__init__.py
+++ b/modules/stock_package_shipping/__init__.py
@@ -8,7 +8,6 @@ from . import carrier, stock
def register():
Pool.register(
- stock.PackageType,
stock.Package,
stock.ShipmentOut,
stock.ShipmentInReturn,
diff --git a/modules/stock_package_shipping/stock.py b/modules/stock_package_shipping/stock.py
index 916b343456..010dd0350e 100644
--- a/modules/stock_package_shipping/stock.py
+++ b/modules/stock_package_shipping/stock.py
@@ -9,7 +9,7 @@ from trytond.i18n import gettext
from trytond.model import ModelView, Workflow, fields
from trytond.model.exceptions import AccessError
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Bool, Eval, Id
+from trytond.pyson import Eval
from trytond.report import Report
from trytond.transaction import Transaction
from trytond.wizard import StateAction, StateTransition, Wizard
@@ -24,76 +24,7 @@ else:
file_id = store_prefix = None
-class DimensionsMixin(object):
- __slots__ = ()
-
- length = fields.Float('Length', digits=(16, Eval('length_digits', 2)))
- length_uom = fields.Many2One('product.uom', 'Length Unit',
- domain=[
- ('category', '=', Id('product', 'uom_cat_length')),
- ],
- states={
- 'required': Bool(Eval('length')),
- },
- depends={'length_digits'})
- length_digits = fields.Function(fields.Integer('Length Digits'),
- 'on_change_with_length_digits')
- height = fields.Float('Height', digits=(16, Eval('height_digits', 2)))
- height_uom = fields.Many2One('product.uom', 'Height Unit',
- domain=[
- ('category', '=', Id('product', 'uom_cat_length')),
- ],
- states={
- 'required': Bool(Eval('height')),
- },
- depends={'height_digits'})
- height_digits = fields.Function(fields.Integer('Height Digits'),
- 'on_change_with_height_digits')
- width = fields.Float('Width', digits=(16, Eval('width_digits', 2)))
- width_uom = fields.Many2One('product.uom', 'Width Unit',
- domain=[
- ('category', '=', Id('product', 'uom_cat_length')),
- ],
- states={
- 'required': Bool(Eval('width')),
- },
- depends={'width_digits'})
- width_digits = fields.Function(fields.Integer('Width Digits'),
- 'on_change_with_width_digits')
-
- @fields.depends('length_uom')
- def on_change_with_length_digits(self, name=None):
- return (self.length_uom.digits if self.length_uom
- else self.default_length_digits())
-
- @fields.depends('height_uom')
- def on_change_with_height_digits(self, name=None):
- return (self.height_uom.digits if self.height_uom
- else self.default_height_digits())
-
- @fields.depends('width_uom')
- def on_change_with_width_digits(self, name=None):
- return (self.width_uom.digits if self.width_uom
- else self.default_width_digits())
-
- @classmethod
- def default_length_digits(cls):
- return 2
-
- @classmethod
- def default_height_digits(cls):
- return 2
-
- @classmethod
- def default_width_digits(cls):
- return 2
-
-
-class PackageType(DimensionsMixin, metaclass=PoolMeta):
- __name__ = 'stock.package.type'
-
-
-class Package(DimensionsMixin, metaclass=PoolMeta):
+class Package(metaclass=PoolMeta):
__name__ = 'stock.package'
shipping_reference = fields.Char('Shipping Reference',
@@ -170,17 +101,6 @@ class Package(DimensionsMixin, metaclass=PoolMeta):
('shipping_reference', *clause[1:]),
]
- @fields.depends('type')
- def on_change_type(self):
- super().on_change_type()
- if self.type:
- self.length = self.type.length
- self.length_uom = self.type.length_uom
- self.height = self.type.height
- self.height_uom = self.type.height_uom
- self.width = self.type.width
- self.width_uom = self.type.width_uom
-
@classmethod
def copy(cls, packages, default=None):
if default is None:
diff --git a/modules/stock_package_shipping/stock.xml b/modules/stock_package_shipping/stock.xml
index 812926116c..10a6374dde 100644
--- a/modules/stock_package_shipping/stock.xml
+++ b/modules/stock_package_shipping/stock.xml
@@ -4,12 +4,6 @@ this repository contains the full copyright notices and license terms. -->
-
- stock.package.type
-
- package_type_form
-
-
stock.package
diff --git a/modules/stock_package_shipping/view/package_form.xml b/modules/stock_package_shipping/view/package_form.xml
index dcfc93e15b..f8265323c7 100644
--- a/modules/stock_package_shipping/view/package_form.xml
+++ b/modules/stock_package_shipping/view/package_form.xml
@@ -2,19 +2,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/stock_package_shipping/view/package_type_form.xml b/modules/stock_package_shipping/view/package_type_form.xml
deleted file mode 100644
index 5427708fff..0000000000
--- a/modules/stock_package_shipping/view/package_type_form.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-