From 1fb0ee2a59ad8b1fc93c71ab4fdea50c1a74bedb Mon Sep 17 00:00:00 2001 From: gaelTorrecillas Date: Fri, 17 Jan 2025 10:05:27 +0100 Subject: [PATCH] test --- packaging_uom/tests/test_product_packaging.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packaging_uom/tests/test_product_packaging.py b/packaging_uom/tests/test_product_packaging.py index 523368dc138..bc9caa69178 100644 --- a/packaging_uom/tests/test_product_packaging.py +++ b/packaging_uom/tests/test_product_packaging.py @@ -11,6 +11,7 @@ def setUpClass(cls): cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) cls.packaging_obj = cls.env["product.packaging"] cls.uom_obj = cls.env["uom.uom"] + cls.category_obj = cls.env["uom.category"] cls.uom_unit = cls.env.ref("uom.product_uom_unit") cls.uom_dozen = cls.env.ref("uom.product_uom_dozen") cls.product_dozen = cls.env["product.product"].create( @@ -19,6 +20,11 @@ def setUpClass(cls): cls.product_unit = cls.env["product.product"].create( {"name": "PRODUCT UNIT", "uom_id": cls.uom_unit.id} ) + cls.categ_kgm_uom = cls.env.ref("uom.product_uom_categ_kgm") + cls.categ_unit_uom = cls.env.ref("uom.product_uom_categ_unit") + cls.product_kgm = cls.env["product.product"].create( + {"name": "PRODUCT KGM", "uom_id": cls.categ_kgm_uom.id} + ) def test_compute_quantity_by_package(self): """Create a packagings with uom product_uom_dozen on @@ -142,6 +148,26 @@ def test_compute_quantity_by_package(self): ) self.assertEqual(1, len(uom_524)) + def test_onchange_product_id(self): + """ + Create a packagings with uom product_dozen + * product_kgm (uom is categ_kgm_uom) + * product_unit (uom is product_uom_kgm) + Result should be : + * uom_categ_domain_id -> categ_unit_uom + Update product_packaging_unit to set this product_unit + Result should be : + * uom_categ_domain_id -> categ_unit_uom + """ + + product_packaging = self.packaging_obj.create( + {"name": "PACKAGING TEST", "product_id": self.product_kgm.id} + ) + self.assertEqual(self.categ_unit_uom, product_packaging.uom_categ_domain_id) + product_packaging.product_id = self.product_unit + self.assertEqual(self.categ_unit_uom, product_packaging.uom_categ_domain_id) + + # def test_packaging_qty_zero(self): # """ # To avoid changing standard behaviour, we affect the default