mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	Allow completion of partially allocated build outputs
- Requires manual acceptance from user
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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) { | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user