diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 2b97b2d6d4..6d5ac73081 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -319,6 +319,30 @@ class Build(MPTTModel): self.status = BuildStatus.COMPLETE self.save() + def isFullyAllocated(self): + """ + Return True if this build has been fully allocated. + """ + + bom_items = self.part.bom_items.all() + + for item in bom_items: + part = item.sub_part + + print("Checking:", part) + + if not self.isPartFullyAllocated(part): + return False + + return True + + def isPartFullyAllocated(self, part): + """ + Check if a given Part is fully allocated for this Build + """ + + return self.getAllocatedQuantity(part) >= self.getRequiredQuantity(part) + def getRequiredQuantity(self, part): """ Calculate the quantity of required to make this build. """ diff --git a/InvenTree/build/templates/build/complete.html b/InvenTree/build/templates/build/complete.html index 230092d766..a75cee2785 100644 --- a/InvenTree/build/templates/build/complete.html +++ b/InvenTree/build/templates/build/complete.html @@ -1,42 +1,37 @@ {% extends "modal_form.html" %} +{% load i18n %} {% block pre_form_content %} -Build: {{ build.title }} - {{ build.quantity }} x {{ build.part.full_name }} -
-Are you sure you want to mark this build as complete? -
-{% if taking %} -The following items will be removed from stock: - - - - - - - -{% for item in taking %} - - - - - - -{% endfor %} -
PartQuantityLocation
- {% include "hover_image.html" with image=item.stock_item.part.image hover=True %} - - {{ item.stock_item.part.full_name }}
- {{ item.stock_item.part.description }} -
{{ item.quantity }}{{ item.stock_item.location }}
+

{% trans "Build" %} - {{ build }}

+ +{% if not build.isFullyAllocated %} +
+

{% trans "Warning: Build order allocation is not complete" %}

+ {% trans "Build Order has not been fully allocated. Ensure that all Stock Items have been allocated to the Build" %} +
{% else %} -No parts have been allocated to this build. +
+

{% trans "Build order allocation is complete" %}

+
{% endif %} -
-The following items will be created: + +
+

{% trans "The following actions will be performed:" %}

+ +
+
- {% include "hover_image.html" with image=build.part.image hover=True %} - {{ build.quantity }} x {{ build.part.full_name }} +
+ {% trans "The following items will be created" %} +
+
+ {% include "hover_image.html" with image=build.part.image hover=True %} + {{ build.quantity }} x {{ build.part.full_name }} +
{% endblock %} \ No newline at end of file