Skip to content

Commit 3e8a7ec

Browse files
Fix references for PartCategoryParameterTemplate
1 parent 93a8626 commit 3e8a7ec

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

inventree/part.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ def getCategory(self):
2424

2525
def getTemplate(self):
2626
"""Return the referenced ParameterTemplate instance"""
27-
return PartParameterTemplate(self._api, self.parameter_template)
27+
28+
template_id = getattr(self, 'template', None) or getattr(self, 'parameter_template', None)
29+
30+
if self._api.api_version < inventree.base.ParameterTemplate.MIN_API_VERSION:
31+
# Return legacy PartParameterTemplate object
32+
return PartParameterTemplate(self._api, template_id)
33+
34+
return inventree.base.ParameterTemplate(self._api, template_id)
2835

2936

3037
class PartCategory(inventree.base.MetadataMixin, inventree.base.InventreeObject):

test/test_part.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_part_category_parameter_templates(self):
150150
self.api,
151151
data={
152152
'category': electronics.pk,
153-
'parameter_template': template.pk,
153+
'template': template.pk,
154154
'default_value': 123,
155155
}
156156
)

0 commit comments

Comments
 (0)