diff --git a/delivery_carrier_package_measure_required/__manifest__.py b/delivery_carrier_package_measure_required/__manifest__.py
index fa9a340b1e..d6c81469b2 100644
--- a/delivery_carrier_package_measure_required/__manifest__.py
+++ b/delivery_carrier_package_measure_required/__manifest__.py
@@ -4,7 +4,7 @@
Allow the configuration of which package measurements are required
on a delivery carrier basis.
""",
- "version": "14.0.1.0.2",
+ "version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/delivery-carrier",
@@ -15,7 +15,7 @@
"stock_quant_package_dimension",
],
"data": [
- "views/product_packaging.xml",
+ "views/stock_package_type_views.xml",
"wizard/choose_delivery_package.xml",
],
"installable": True,
diff --git a/delivery_carrier_package_measure_required/models/__init__.py b/delivery_carrier_package_measure_required/models/__init__.py
index cb7177dedf..2f66e4bb1d 100644
--- a/delivery_carrier_package_measure_required/models/__init__.py
+++ b/delivery_carrier_package_measure_required/models/__init__.py
@@ -1,3 +1,3 @@
-from . import product_packaging
+from . import stock_package_type
from . import stock_picking
from . import stock_quant_package
diff --git a/delivery_carrier_package_measure_required/models/product_packaging.py b/delivery_carrier_package_measure_required/models/stock_package_type.py
similarity index 84%
rename from delivery_carrier_package_measure_required/models/product_packaging.py
rename to delivery_carrier_package_measure_required/models/stock_package_type.py
index 127d8bd8b5..a63d7afdc7 100644
--- a/delivery_carrier_package_measure_required/models/product_packaging.py
+++ b/delivery_carrier_package_measure_required/models/stock_package_type.py
@@ -4,8 +4,8 @@
from odoo import fields, models
-class ProductPackaging(models.Model):
- _inherit = "product.packaging"
+class StockPackageType(models.Model):
+ _inherit = "stock.package.type"
package_height_required = fields.Boolean(string="Height required")
package_length_required = fields.Boolean(string="Length required")
diff --git a/delivery_carrier_package_measure_required/models/stock_picking.py b/delivery_carrier_package_measure_required/models/stock_picking.py
index 0654c14b43..77489f5758 100644
--- a/delivery_carrier_package_measure_required/models/stock_picking.py
+++ b/delivery_carrier_package_measure_required/models/stock_picking.py
@@ -19,3 +19,21 @@ def _check_required_package_measurement(self):
def button_validate(self):
self._check_required_package_measurement()
return super().button_validate()
+
+ def _put_in_pack(self, move_line_ids, create_package_level=True):
+ res = super()._put_in_pack(
+ move_line_ids, create_package_level=create_package_level
+ )
+ package_length = self._context.get("choose_delivery_package_length", 0)
+ package_width = self._context.get("choose_delivery_package_width", 0)
+ package_height = self._context.get("choose_delivery_package_height", 0)
+
+ res.write(
+ {
+ "pack_length": package_length,
+ "width": package_width,
+ "height": package_height,
+ }
+ )
+
+ return res
diff --git a/delivery_carrier_package_measure_required/models/stock_quant_package.py b/delivery_carrier_package_measure_required/models/stock_quant_package.py
index eb966891c6..c3ebdb3582 100644
--- a/delivery_carrier_package_measure_required/models/stock_quant_package.py
+++ b/delivery_carrier_package_measure_required/models/stock_quant_package.py
@@ -8,10 +8,10 @@
class StockQuantPackage(models.Model):
_inherit = "stock.quant.package"
- length_required = fields.Boolean(related="packaging_id.package_length_required")
- width_required = fields.Boolean(related="packaging_id.package_width_required")
- height_required = fields.Boolean(related="packaging_id.package_height_required")
- weight_required = fields.Boolean(related="packaging_id.package_weight_required")
+ length_required = fields.Boolean(related="package_type_id.package_length_required")
+ width_required = fields.Boolean(related="package_type_id.package_width_required")
+ height_required = fields.Boolean(related="package_type_id.package_height_required")
+ weight_required = fields.Boolean(related="package_type_id.package_weight_required")
# The boolean field use to check if a dimension is required are intentionally left out.
# To not raise error when changing packaging configuration.
diff --git a/delivery_carrier_package_measure_required/readme/DESCRIPTION.rst b/delivery_carrier_package_measure_required/readme/DESCRIPTION.rst
index 51666e8352..e2db95e6c3 100644
--- a/delivery_carrier_package_measure_required/readme/DESCRIPTION.rst
+++ b/delivery_carrier_package_measure_required/readme/DESCRIPTION.rst
@@ -2,7 +2,7 @@ This module adds the possibility to flag some measurements on package to be requ
It depends on the `stock_quant_package_dimension` which adds more dimensions on packages.
-The required measurement can be flagged on the product packaging.
+The required measurement can be flagged on the package type.
Then the dimension can be set on the wizard displayed by the Put In Pack button.
diff --git a/delivery_carrier_package_measure_required/tests/test_delivery_carrier_package_measure_require.py b/delivery_carrier_package_measure_required/tests/test_delivery_carrier_package_measure_require.py
index 0057beb5e5..c1305a5f90 100644
--- a/delivery_carrier_package_measure_required/tests/test_delivery_carrier_package_measure_require.py
+++ b/delivery_carrier_package_measure_required/tests/test_delivery_carrier_package_measure_require.py
@@ -12,7 +12,7 @@ class TestDeliveryCarrierPackageMeasureRequire(TestPackingCommon):
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
- cls.normal_carrier = cls.env.ref("delivery.normal_delivery_carrier")
+ cls.normal_carrier = cls.env.ref("delivery.free_delivery_carrier")
cls.uom_kg = cls.env.ref("uom.product_uom_kgm")
cls.product_aw = cls.env["product.product"].create(
{
@@ -23,7 +23,7 @@ def setUpClass(cls):
"uom_po_id": cls.uom_kg.id,
}
)
- cls.packaging = cls.env["product.packaging"].create(
+ cls.packaging = cls.env["stock.package.type"].create(
{"name": "Test Delivery Packaging"}
)
cls.env["stock.quant"]._update_available_quantity(
@@ -38,12 +38,13 @@ def setUpClass(cls):
"carrier_id": cls.normal_carrier.id,
}
)
- cls.env["stock.move.line"].create(
+ cls.env["stock.move"].create(
{
+ "name": cls.product_aw.name,
"product_id": cls.product_aw.id,
- "product_uom_id": cls.uom_kg.id,
+ "product_uom_qty": 5,
+ "product_uom": cls.uom_kg.id,
"picking_id": cls.pick.id,
- "qty_done": 5,
"location_id": cls.stock_location.id,
"location_dest_id": cls.customer_location.id,
}
@@ -58,7 +59,7 @@ def setUpClass(cls):
)
pack_wiz.action_put_in_pack()
cls.package = cls.pick.move_line_ids.mapped("result_package_id")
- cls.package.packaging_id = cls.packaging
+ cls.package.package_type_id = cls.packaging
def test_force_check_required_measurement(self):
self.packaging.package_length_required = True
diff --git a/delivery_carrier_package_measure_required/views/product_packaging.xml b/delivery_carrier_package_measure_required/views/product_packaging.xml
deleted file mode 100644
index 12dbe65106..0000000000
--- a/delivery_carrier_package_measure_required/views/product_packaging.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-