mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Do not enforce unit type conversion for part parameters (#5160)
* Do not enforce unit type conversion for part parameters - Still convert to "native value" (if possible) * update unit tests
This commit is contained in:
parent
d52a839cf2
commit
9ebbc2f9f6
@ -3532,15 +3532,6 @@ class PartParameter(MetadataMixin, models.Model):
|
||||
|
||||
super().clean()
|
||||
|
||||
# Validate the parameter data against the template units
|
||||
if self.template.units:
|
||||
try:
|
||||
InvenTree.conversion.convert_physical_value(self.data, self.template.units)
|
||||
except ValidationError as e:
|
||||
raise ValidationError({
|
||||
'data': e.message
|
||||
})
|
||||
|
||||
# Validate the parameter data against the template choices
|
||||
if choices := self.template.get_choices():
|
||||
if self.data not in choices:
|
||||
|
@ -168,11 +168,10 @@ class ParameterTests(TestCase):
|
||||
param = PartParameter(part=prt, template=template, data=value)
|
||||
param.full_clean()
|
||||
|
||||
# Test that invalid parameters fail
|
||||
# Invalid units also pass, but will be converted to the template units
|
||||
for value in ['3 Amps', '-3 zogs', '3.14F']:
|
||||
param = PartParameter(part=prt, template=template, data=value)
|
||||
with self.assertRaises(django_exceptions.ValidationError):
|
||||
param.full_clean()
|
||||
param.full_clean()
|
||||
|
||||
def test_param_unit_conversion(self):
|
||||
"""Test that parameters are correctly converted to template units"""
|
||||
|
Loading…
Reference in New Issue
Block a user