2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

Validate and save the new serailizer

This commit is contained in:
Oliver Walters
2022-01-07 11:33:27 +11:00
parent 960784644f
commit 12b3a5c9cc
5 changed files with 84 additions and 2 deletions

View File

@ -250,13 +250,35 @@ class BuildCompleteSerializer(serializers.Serializer):
help_text=_('Accept that stock items have not been fully allocated to this build order'),
)
def validate_accept_unallocated(self, value):
build = self.context['build']
if not build.areUntrackedPartsFullyAllocated() and not value:
raise ValidationError(_('Required stock has not been fully allocated'))
return value
accept_incomplete = serializers.BooleanField(
label=_('Accept Incomplete'),
help_text=_('Accept that the required number of build outputs have not been completed'),
)
def validate_accept_incomplete(self, value):
build = self.context['build']
if build.remaining > 0 and not value:
raise ValidationError(_('Required build quantity has not been completed'))
return value
def save(self):
pass
request = self.context['request']
build = self.context['build']
build.complete_build(request.user)
class BuildUnallocationSerializer(serializers.Serializer):