From 2b99cf353a525e019a6864a4dc4503cb90a96805 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 27 Apr 2020 20:16:41 +1000 Subject: [PATCH] Fix for build complete form --- InvenTree/build/models.py | 2 +- InvenTree/build/templates/build/complete.html | 10 +++++----- InvenTree/order/models.py | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index f58f3b4206..c6b6a741da 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -323,7 +323,7 @@ class Build(MPTTModel): if not self.isPartFullyAllocated(part): return False - return True + return True def isPartFullyAllocated(self, part): """ diff --git a/InvenTree/build/templates/build/complete.html b/InvenTree/build/templates/build/complete.html index a75cee2785..a48b831645 100644 --- a/InvenTree/build/templates/build/complete.html +++ b/InvenTree/build/templates/build/complete.html @@ -5,15 +5,15 @@

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

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

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

+
+{% else %}

{% 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 %} -
-

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

-
{% endif %}
diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 0b2ebd3707..6198eb16bc 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -541,7 +541,8 @@ class SalesOrderAllocation(models.Model): if self.quantity > self.item.quantity: errors['quantity'] = _('Allocation quantity cannot exceed stock quantity') - if self.item.quantity - self.item.allocation_count() < self.quantity: + # TODO: The logic here needs improving. Do we need to subtract our own amount, or something? + if self.item.quantity - self.item.allocation_count() + self.quantity < self.quantity: errors['quantity'] = _('StockItem is over-allocated') if self.quantity <= 0: