Skip to content

Commit 5e2d4f6

Browse files
lanto-razafindrabemajouda
authored andcommittedMay 17, 2023
TA#53113 [ADD] adding unity of measure on two modules
1 parent a2bf2ad commit 5e2d4f6

File tree

3 files changed

+74
-31
lines changed

3 files changed

+74
-31
lines changed
 

‎product_packaging_dimension_decimal/models/product_packaging.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def _get_uom_domain(self):
1616
(
1717
self.env.ref("uom.product_uom_foot").id,
1818
self.env.ref("uom.product_uom_meter").id,
19+
self.env.ref("uom.product_uom_inch").id,
20+
self.env.ref("uom.product_uom_cm").id,
1921
)
2022
)
2123
return [("id", "in", uom_ids)]
@@ -44,4 +46,3 @@ def _get_default_uom(self):
4446
domain=_get_uom_domain,
4547
default=_get_default_uom
4648
)
47-

‎stock_product_packaging_dimension/models/stock_quant_package.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def _get_uom_domain(self):
1616
(
1717
self.env.ref("uom.product_uom_foot").id,
1818
self.env.ref("uom.product_uom_meter").id,
19+
self.env.ref("uom.product_uom_inch").id,
20+
self.env.ref("uom.product_uom_cm").id,
1921
)
2022
)
2123
return [("id", "in", uom_ids)]
@@ -44,4 +46,3 @@ def _get_default_uom(self):
4446
domain=_get_uom_domain,
4547
default=_get_default_uom
4648
)
47-

‎stock_product_packaging_dimension/tests/test_stock_quant_package_dimension.py

+70-29
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,83 @@
55

66

77
class TestStockQuantPackageDimension(common.SavepointCase):
8-
98
@classmethod
109
def setUpClass(cls):
1110
super().setUpClass()
12-
cls.foot = cls.env.ref('uom.product_uom_foot')
13-
cls.meter = cls.env.ref('uom.product_uom_meter')
11+
cls.foot = cls.env.ref("uom.product_uom_foot")
12+
cls.meter = cls.env.ref("uom.product_uom_meter")
13+
cls.inch = cls.env.ref("uom.product_uom_inch")
14+
cls.cm = cls.env.ref("uom.product_uom_cm")
1415
cls.height = 0.38
1516
cls.packaging_length = 0.80
1617
cls.width = 3.77
1718

1819
def test_stock_quant_dimension_with_decimal(self):
19-
self.stock_quant_package = self.env['stock.quant.package'].create({
20-
'name': 'Test stock quant package',
21-
'height': self.height,
22-
'packaging_length': self.packaging_length,
23-
'width': self.width,
24-
})
20+
self.stock_quant_package = self.env["stock.quant.package"].create(
21+
{
22+
"name": "Test stock quant package",
23+
"height": self.height,
24+
"packaging_length": self.packaging_length,
25+
"width": self.width,
26+
}
27+
)
2528

2629
self.stock_quant_package.refresh()
2730

2831
self.assertEqual(self.stock_quant_package.height, self.height)
2932
self.assertEqual(
30-
self.stock_quant_package.packaging_length, self.packaging_length)
33+
self.stock_quant_package.packaging_length, self.packaging_length
34+
)
3135
self.assertEqual(self.stock_quant_package.width, self.width)
3236

3337
def test_stock_quant_package_dimension_uom(self):
34-
self.stock_quant_package_ft = self.env['stock.quant.package'].create({
35-
'name': 'Test stock quant package - foot',
36-
'height': self.height,
37-
'height_uom_id': self.foot.id,
38-
'packaging_length': self.packaging_length,
39-
'length_uom_id': self.foot.id,
40-
'width': self.width,
41-
'width_uom_id': self.foot.id,
42-
})
43-
44-
self.stock_quant_package_m = self.env['stock.quant.package'].create({
45-
'name': 'Test stock quant package - meter',
46-
'height': self.height,
47-
'height_uom_id': self.meter.id,
48-
'packaging_length': self.packaging_length,
49-
'length_uom_id': self.meter.id,
50-
'width': self.width,
51-
'width_uom_id': self.meter.id,
52-
})
38+
self.stock_quant_package_ft = self.env["stock.quant.package"].create(
39+
{
40+
"name": "Test stock quant package - foot",
41+
"height": self.height,
42+
"height_uom_id": self.foot.id,
43+
"packaging_length": self.packaging_length,
44+
"length_uom_id": self.foot.id,
45+
"width": self.width,
46+
"width_uom_id": self.foot.id,
47+
}
48+
)
49+
50+
self.stock_quant_package_m = self.env["stock.quant.package"].create(
51+
{
52+
"name": "Test stock quant package - meter",
53+
"height": self.height,
54+
"height_uom_id": self.meter.id,
55+
"packaging_length": self.packaging_length,
56+
"length_uom_id": self.meter.id,
57+
"width": self.width,
58+
"width_uom_id": self.meter.id,
59+
}
60+
)
61+
62+
self.stock_quant_package_inch = self.env["stock.quant.package"].create(
63+
{
64+
"name": "Test stock quant package - inch",
65+
"height": self.height,
66+
"height_uom_id": self.inch.id,
67+
"packaging_length": self.packaging_length,
68+
"length_uom_id": self.inch.id,
69+
"width": self.width,
70+
"width_uom_id": self.inch.id,
71+
}
72+
)
73+
74+
self.stock_quant_package_cm = self.env["stock.quant.package"].create(
75+
{
76+
"name": "Test stock quant package - cm",
77+
"height": self.height,
78+
"height_uom_id": self.cm.id,
79+
"packaging_length": self.packaging_length,
80+
"length_uom_id": self.cm.id,
81+
"width": self.width,
82+
"width_uom_id": self.cm.id,
83+
}
84+
)
5385

5486
self.stock_quant_package_ft.refresh()
5587
self.stock_quant_package_m.refresh()
@@ -60,3 +92,12 @@ def test_stock_quant_package_dimension_uom(self):
6092
self.assertEqual(self.stock_quant_package_m.height_uom_id, self.meter)
6193
self.assertEqual(self.stock_quant_package_m.length_uom_id, self.meter)
6294
self.assertEqual(self.stock_quant_package_m.width_uom_id, self.meter)
95+
self.assertEqual(
96+
self.stock_quant_package_inch.height_uom_id, self.inch)
97+
self.assertEqual(
98+
self.stock_quant_package_inch.length_uom_id, self.inch)
99+
self.assertEqual(
100+
self.stock_quant_package_inch.width_uom_id, self.inch)
101+
self.assertEqual(self.stock_quant_package_cm.height_uom_id, self.cm)
102+
self.assertEqual(self.stock_quant_package_cm.length_uom_id, self.cm)
103+
self.assertEqual(self.stock_quant_package_cm.width_uom_id, self.cm)

0 commit comments

Comments
 (0)
Please sign in to comment.