From 318e84883a413274c3dc6dccd8f0998e8897fe40 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 1 Feb 2022 15:51:38 +1100 Subject: [PATCH 1/2] Adds a warning if no build outputs are created --- InvenTree/build/templates/build/build_base.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index ae6ea6d4d3..7340f1486d 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -90,6 +90,11 @@ src="{% static 'img/blank_image.png' %}"
+ {% if not build.has_build_outputs %} +
+ {% trans "No build outputs have been created for this build order" %}
+
+ {% endif %} {% if build.sales_order %}
{% object_link 'so-detail' build.sales_order.id build.sales_order as link %} From 00d7cf88e8957eb823dff8c0c525503d412ca31d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 1 Feb 2022 15:58:18 +1100 Subject: [PATCH 2/2] Throw validation error if no build outputs have been started --- InvenTree/build/models.py | 3 +++ InvenTree/build/serializers.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 8cad93352b..0eeffd107d 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -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. diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py index fb34a40a16..2508b02927 100644 --- a/InvenTree/build/serializers.py +++ b/InvenTree/build/serializers.py @@ -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):