|
| 1 | +# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
| 2 | +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). |
| 3 | + |
| 4 | +from odoo.tests import common |
| 5 | + |
| 6 | + |
| 7 | +class TestProductPackagingUom(common.SavepointCase): |
| 8 | + |
| 9 | + @classmethod |
| 10 | + def setUpClass(cls): |
| 11 | + super().setUpClass() |
| 12 | + cls.foot = cls.env.ref('uom.product_uom_foot') |
| 13 | + cls.meter = cls.env.ref('uom.product_uom_meter') |
| 14 | + cls.height = 1.35 |
| 15 | + cls.packaging_length = 1.50 |
| 16 | + cls.width = 2.88 |
| 17 | + |
| 18 | + def test_foot_height_value_on_measure_is_float(self): |
| 19 | + self.product_package = self.env['product.packaging'].create({ |
| 20 | + 'name': 'Test product packaging', |
| 21 | + 'height': self.height, |
| 22 | + 'packaging_length': self.packaging_length, |
| 23 | + 'width': self.width, |
| 24 | + }) |
| 25 | + |
| 26 | + self.product_package.refresh() |
| 27 | + |
| 28 | + self.assertEqual(self.product_package.height, self.height) |
| 29 | + self.assertEqual(self.product_package.packaging_length, self.packaging_length) |
| 30 | + self.assertEqual(self.product_package.width, self.width) |
| 31 | + |
| 32 | + def test_product_packaging_uom(self): |
| 33 | + self.product_package_1_ft = self.env['product.packaging'].create({ |
| 34 | + 'name': 'Test product packaging - foot', |
| 35 | + 'height': self.height, |
| 36 | + 'height_uom_id': self.foot.id, |
| 37 | + 'packaging_length': self.packaging_length, |
| 38 | + 'length_uom_id': self.foot.id, |
| 39 | + 'width': self.width, |
| 40 | + 'width_uom_id': self.foot.id, |
| 41 | + }) |
| 42 | + |
| 43 | + self.product_package_2_m = self.env['product.packaging'].create({ |
| 44 | + 'name': 'Test product packaging - meter', |
| 45 | + 'height': self.height, |
| 46 | + 'height_uom_id': self.meter.id, |
| 47 | + 'packaging_length': self.packaging_length, |
| 48 | + 'length_uom_id': self.meter.id, |
| 49 | + 'width': self.width, |
| 50 | + 'width_uom_id': self.meter.id, |
| 51 | + }) |
| 52 | + |
| 53 | + self.product_package_1_ft.refresh() |
| 54 | + self.product_package_2_m.refresh() |
| 55 | + |
| 56 | + self.assertEqual(self.product_package_1_ft.height_uom_id, self.foot) |
| 57 | + self.assertEqual(self.product_package_1_ft.length_uom_id, self.foot) |
| 58 | + self.assertEqual(self.product_package_1_ft.width_uom_id, self.foot) |
| 59 | + self.assertEqual(self.product_package_2_m.height_uom_id, self.meter) |
| 60 | + self.assertEqual(self.product_package_2_m.length_uom_id, self.meter) |
| 61 | + self.assertEqual(self.product_package_2_m.width_uom_id, self.meter) |
0 commit comments