Skip to content

Commit e4073cc

Browse files
[16.0][FIX] product_logistics_uom, in variant creation add fields value of template
1 parent 3a646a0 commit e4073cc

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

product_logistics_uom/models/product_template.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,19 @@ def _compute_show_weight_uom_warning(self):
159159
)
160160
for template in self - unique_variants:
161161
template.show_weight_uom_warning = False
162+
163+
def _prepare_variant_values(self, combination):
164+
res = super()._prepare_variant_values(combination)
165+
if self.product_volume:
166+
res.update(
167+
{
168+
"product_volume": self.product_volume,
169+
}
170+
)
171+
if self.product_weight:
172+
res.update(
173+
{
174+
"product_weight": self.product_weight,
175+
}
176+
)
177+
return res

product_logistics_uom/tests/test_product_logistics_uom.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,14 @@ def test_template_with_variant(self):
111111
self.assertEqual(template.weight, 10.0)
112112
self.assertEqual(template.product_volume, 10.0)
113113
self.assertEqual(template.product_weight, 10.0)
114+
115+
def test_template_create(self):
116+
template = self.env["product.template"].create(
117+
{
118+
"name": "Template",
119+
"product_volume": 10,
120+
"product_weight": 10,
121+
}
122+
)
123+
self.assertEqual(template.product_volume, 10)
124+
self.assertEqual(template.product_weight, 10)

0 commit comments

Comments
 (0)