mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56:45 +00:00
Validate that the BuildItem quantity is an integer
This commit is contained in:
parent
fdcef7b699
commit
28460b3023
@ -32,7 +32,7 @@ from part import models as PartModels
|
|||||||
|
|
||||||
|
|
||||||
class Build(MPTTModel):
|
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:
|
Attributes:
|
||||||
part: The part to be built (from component BOM items)
|
part: The part to be built (from component BOM items)
|
||||||
@ -70,15 +70,14 @@ class Build(MPTTModel):
|
|||||||
|
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
try:
|
# Build quantity must be an integer
|
||||||
if self.part.trackable:
|
# 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")
|
|
||||||
})
|
|
||||||
except PartModels.Part.DoesNotExist:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
if not self.quantity == int(self.quantity):
|
||||||
|
raise ValidationError({
|
||||||
|
'quantity': _("Build quantity must be integer value for trackable parts")
|
||||||
|
})
|
||||||
|
|
||||||
reference = models.CharField(
|
reference = models.CharField(
|
||||||
unique=True,
|
unique=True,
|
||||||
max_length=64,
|
max_length=64,
|
||||||
|
@ -157,6 +157,7 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
'customer',
|
'customer',
|
||||||
'build_order',
|
'build_order',
|
||||||
'in_stock',
|
'in_stock',
|
||||||
|
'is_building',
|
||||||
'link',
|
'link',
|
||||||
'location',
|
'location',
|
||||||
'location_detail',
|
'location_detail',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user