From 774e26eb1959593ee47086d120d356ae326f4ada Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 28 May 2020 20:33:33 +1000 Subject: [PATCH 1/2] Mark some fields as not-required via the API --- InvenTree/stock/serializers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 91d9e03016..bde9b2b25b 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -104,12 +104,14 @@ class StockItemSerializer(InvenTreeModelSerializer): location_detail = LocationBriefSerializer(source='location', many=False, read_only=True) supplier_part_detail = SupplierPartSerializer(source='supplier_part', many=False, read_only=True) - tracking_items = serializers.IntegerField(source='tracking_info_count') + tracking_items = serializers.IntegerField(source='tracking_info_count', read_only=True, required=False) quantity = serializers.FloatField() - allocated = serializers.FloatField(source='allocation_count') + allocated = serializers.FloatField(source='allocation_count', required=False) - required_tests = serializers.IntegerField(source='required_test_count', read_only=True) + serial = serializers.IntegerField(required=False) + + required_tests = serializers.IntegerField(source='required_test_count', read_only=True, required=False) def __init__(self, *args, **kwargs): From 59d9e430b40ebda2c3b23ddfc416c5250982d695 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 28 May 2020 20:38:24 +1000 Subject: [PATCH 2/2] Remove unique-together requirement - This is handled manually via the validate_unique function --- .../stock/migrations/0044_auto_20200528_1036.py | 17 +++++++++++++++++ InvenTree/stock/models.py | 5 ----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 InvenTree/stock/migrations/0044_auto_20200528_1036.py diff --git a/InvenTree/stock/migrations/0044_auto_20200528_1036.py b/InvenTree/stock/migrations/0044_auto_20200528_1036.py new file mode 100644 index 0000000000..2d026fe597 --- /dev/null +++ b/InvenTree/stock/migrations/0044_auto_20200528_1036.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0.5 on 2020-05-28 10:36 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('stock', '0043_auto_20200525_0420'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='stockitem', + unique_together=set(), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 3d9394979c..7bebdefaba 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -292,11 +292,6 @@ class StockItem(MPTTModel): def get_part_name(self): return self.part.full_name - class Meta: - unique_together = [ - ('part', 'serial'), - ] - def format_barcode(self): """ Return a JSON string for formatting a barcode for this StockItem. Can be used to perform lookup of a stockitem using barcode