Merge pull request #2584 from SchrodingersGat/build-output-requires

Build output requires
This commit is contained in:
Oliver 2022-02-01 16:35:59 +11:00 committed by GitHub
commit dd3ac58f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -437,6 +437,9 @@ class Build(MPTTModel, ReferenceIndexingMixin):
def output_count(self):
return self.build_outputs.count()
def has_build_outputs(self):
return self.output_count > 0
def get_build_outputs(self, **kwargs):
"""
Return a list of build outputs.

View File

@ -284,6 +284,9 @@ class BuildCompleteSerializer(serializers.Serializer):
if build.incomplete_count > 0:
raise ValidationError(_("Build order has incomplete outputs"))
if not build.has_build_outputs():
raise ValidationError(_("No build outputs have been created for this build order"))
return data
def save(self):

View File

@ -90,6 +90,11 @@ src="{% static 'img/blank_image.png' %}"
</table>
<div class='info-messages'>
{% if not build.has_build_outputs %}
<div class='alert alert-block alert-danger'>
{% trans "No build outputs have been created for this build order" %}<br>
</div>
{% endif %}
{% if build.sales_order %}
<div class='alert alert-block alert-info'>
{% object_link 'so-detail' build.sales_order.id build.sales_order as link %}