From f531e354b95ace9e0673a9b3c27756497cdf7c80 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 28 Apr 2022 21:54:38 +1000 Subject: [PATCH] Allow completion of partially allocated build outputs - Requires manual acceptance from user --- InvenTree/build/api.py | 2 +- InvenTree/build/serializers.py | 15 ++++++++++++++- InvenTree/templates/js/translated/build.js | 6 ++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index 2e2fb53510..22dd6473ab 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -452,7 +452,7 @@ class BuildItemList(generics.ListCreateAPIView): if tracked: queryset = queryset.exclude(install_into=None) else: - queryset = queryest.filter(install_into=None) + queryset = queryset.filter(install_into=None) # Filter by output target output = params.get('output', None) diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index 4b55182563..7df2c474a9 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -161,7 +161,12 @@ class BuildOutputSerializer(serializers.Serializer): # The build output must have all tracked parts allocated if not build.is_fully_allocated(output): - raise ValidationError(_("This build output is not fully allocated")) + + # Check if the user has specified that incomplete allocations are ok + accept_incomplete = InvenTree.helpers.str2bool(self.context['request'].data.get('accept_incomplete_allocation', False)) + + if not accept_incomplete: + raise ValidationError(_("This build output is not fully allocated")) return output @@ -355,6 +360,7 @@ class BuildOutputCompleteSerializer(serializers.Serializer): 'outputs', 'location', 'status', + 'accept_incomplete_allocation', 'notes', ] @@ -377,6 +383,13 @@ class BuildOutputCompleteSerializer(serializers.Serializer): label=_("Status"), ) + accept_incomplete_allocation = serializers.BooleanField( + default=False, + required=False, + label=_('Accept Incomplete Allocation'), + help_text=_('Complete ouputs if stock has not been fully allocated'), + ) + notes = serializers.CharField( label=_("Notes"), required=False, diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 820f78f47b..29683154fe 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -427,6 +427,8 @@ function completeBuildOutputs(build_id, outputs, options={}) { fields: { status: {}, location: {}, + notes: {}, + accept_incomplete_allocation: {}, }, confirm: true, title: '{% trans "Complete Build Outputs" %}', @@ -445,6 +447,8 @@ function completeBuildOutputs(build_id, outputs, options={}) { outputs: [], status: getFormFieldValue('status', {}, opts), location: getFormFieldValue('location', {}, opts), + notes: getFormFieldValue('notes', {}, opts), + accept_incomplete_allocation: getFormFieldValue('accept_incomplete_allocation', {type: 'boolean'}, opts), }; var output_pk_values = []; @@ -1896,8 +1900,6 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) { method: 'POST', fields: {}, preFormContent: html, - confirm: true, - confirmMessage: '{% trans "Confirm stock allocation" %}', title: '{% trans "Allocate Stock Items to Build Order" %}', afterRender: function(fields, options) {