2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Add confirmation for "over-allocated" stock when completing BuildOrder (#3272)

This commit is contained in:
Oliver
2022-06-29 14:59:55 +10:00
committed by GitHub
parent 825e4b4cd8
commit 73445b4b79
3 changed files with 31 additions and 0 deletions

View File

@ -466,6 +466,22 @@ class BuildCancelSerializer(serializers.Serializer):
class BuildCompleteSerializer(serializers.Serializer):
"""DRF serializer for marking a BuildOrder as complete."""
accept_overallocated = serializers.BooleanField(
label=_('Accept Overallocated'),
help_text=_('Accept stock items which have been overallocated to this build order'),
required=False,
default=False,
)
def validate_accept_overallocated(self, value):
"""Check if the 'accept_overallocated' field is required"""
build = self.context['build']
if build.has_overallocated_parts(output=None) and not value:
raise ValidationError(_('Some stock items have been overallocated'))
return value
accept_unallocated = serializers.BooleanField(
label=_('Accept Unallocated'),
help_text=_('Accept that stock items have not been fully allocated to this build order'),