From 28460b30238512eafd9bdc6b4fb6c4b0601b1f73 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 20 Oct 2020 20:42:29 +1100 Subject: [PATCH] Validate that the BuildItem quantity is an integer --- InvenTree/build/models.py | 17 ++++++++--------- InvenTree/stock/serializers.py | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 3afc7d5d10..f4a66e6b6f 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -32,7 +32,7 @@ from part import models as PartModels class Build(MPTTModel): - """ A Build object organises the creation of new parts from the component parts. + """ A Build object organises the creation of new StockItem objects from other existing StockItem objects. Attributes: part: The part to be built (from component BOM items) @@ -70,15 +70,14 @@ class Build(MPTTModel): super().clean() - try: - if self.part.trackable: - if not self.quantity == int(self.quantity): - raise ValidationError({ - 'quantity': _("Build quantity must be integer value for trackable parts") - }) - except PartModels.Part.DoesNotExist: - pass + # Build quantity must be an integer + # Maybe in the future this will be adjusted? + if not self.quantity == int(self.quantity): + raise ValidationError({ + 'quantity': _("Build quantity must be integer value for trackable parts") + }) + reference = models.CharField( unique=True, max_length=64, diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 4a9b5a886b..d257f12f97 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -157,6 +157,7 @@ class StockItemSerializer(InvenTreeModelSerializer): 'customer', 'build_order', 'in_stock', + 'is_building', 'link', 'location', 'location_detail',