diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py
index b8a66a825d..e0c500e5e3 100644
--- a/InvenTree/order/forms.py
+++ b/InvenTree/order/forms.py
@@ -84,9 +84,9 @@ class ReceivePurchaseOrderForm(HelperForm):
location = TreeNodeChoiceField(
queryset=StockLocation.objects.all(),
- required=True,
+ required=False,
label=_("Destination"),
- help_text=_("Receive parts to this location"),
+ help_text=_("Set all received parts listed above to this location (if left blank, use \"Destination\" column value in above table)"),
)
class Meta:
diff --git a/InvenTree/order/templates/order/receive_parts.html b/InvenTree/order/templates/order/receive_parts.html
index bfddf01ce9..847c21b0a3 100644
--- a/InvenTree/order/templates/order/receive_parts.html
+++ b/InvenTree/order/templates/order/receive_parts.html
@@ -12,7 +12,7 @@
{% load crispy_forms_tags %}
-
{% trans "Select parts to receive against this order" %}
+
{% trans "Fill out number of parts received, the status and destination" %}
@@ -55,7 +55,14 @@
- {{ line.get_destination }}
+
+
+
{% crispy form %}
+
+
{{ form_errors }}
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/order/views.py b/InvenTree/order/views.py
index a109b036e0..e8b0dc03e9 100644
--- a/InvenTree/order/views.py
+++ b/InvenTree/order/views.py
@@ -491,6 +491,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
ctx = {
'order': self.order,
'lines': self.lines,
+ 'stock_locations': StockLocation.objects.all(),
}
return ctx
@@ -543,6 +544,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
self.request = request
self.order = get_object_or_404(PurchaseOrder, pk=self.kwargs['pk'])
+ errors = False
self.lines = []
self.destination = None
@@ -557,12 +559,6 @@ class PurchaseOrderReceive(AjaxUpdateView):
except (StockLocation.DoesNotExist, ValueError):
pass
- errors = False
-
- if self.destination is None:
- errors = True
- msg = _("No destination set")
-
# Extract information on all submitted line items
for item in request.POST:
if item.startswith('line-'):
@@ -587,6 +583,21 @@ class PurchaseOrderReceive(AjaxUpdateView):
else:
line.status_code = StockStatus.OK
+ # Check the destination field
+ line.destination = None
+ if self.destination:
+ # If global destination is set, overwrite line value
+ line.destination = self.destination
+ else:
+ destination_key = f'destination-{pk}'
+ destination = request.POST.get(destination_key, None)
+
+ if destination:
+ try:
+ line.destination = StockLocation.objects.get(pk=destination)
+ except (StockLocation.DoesNotExist, ValueError):
+ pass
+
# Check that line matches the order
if not line.order == self.order:
# TODO - Display a non-field error?
@@ -645,7 +656,7 @@ class PurchaseOrderReceive(AjaxUpdateView):
self.order.receive_line_item(
line,
- self.destination,
+ line.destination,
line.receive_quantity,
self.request.user,
status=line.status_code,