From 9ebbc2f9f6731fb323ce57119ae3c0b401c72623 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 4 Jul 2023 21:57:43 +1000 Subject: [PATCH] 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 --- InvenTree/part/models.py | 9 --------- InvenTree/part/test_param.py | 5 ++--- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index fc1cc2e451..cd993ed826 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -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: diff --git a/InvenTree/part/test_param.py b/InvenTree/part/test_param.py index 63a3b4f8d2..13767676c7 100644 --- a/InvenTree/part/test_param.py +++ b/InvenTree/part/test_param.py @@ -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"""