diff --git a/InvenTree/InvenTree/status_codes.py b/InvenTree/InvenTree/status_codes.py index 1b6d77b57d..2082eac70b 100644 --- a/InvenTree/InvenTree/status_codes.py +++ b/InvenTree/InvenTree/status_codes.py @@ -54,6 +54,10 @@ class StatusCode: return codes + @classmethod + def text(cls, key): + return cls.options.get(key, None) + @classmethod def items(cls): return cls.options.items() @@ -204,6 +208,15 @@ class StockStatus(StatusCode): ASSIGNED_TO_OTHER_ITEM, ] + # The following codes are available for receiving goods + RECEIVING_CODES = [ + OK, + ATTENTION, + DAMAGED, + DESTROYED, + REJECTED + ] + class BuildStatus(StatusCode): diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 6198eb16bc..56da6c783d 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -209,7 +209,7 @@ class PurchaseOrder(Order): return self.pending_line_items().count() == 0 @transaction.atomic - def receive_line_item(self, line, location, quantity, user): + def receive_line_item(self, line, location, quantity, user, status=StockStatus.OK): """ Receive a line item (or partial line item) against this PO """ @@ -230,7 +230,9 @@ class PurchaseOrder(Order): supplier_part=line.part, location=location, quantity=quantity, - purchase_order=self) + purchase_order=self, + status=status + ) stock.save() diff --git a/InvenTree/order/templates/order/receive_parts.html b/InvenTree/order/templates/order/receive_parts.html index f71959cdc0..082fe083b9 100644 --- a/InvenTree/order/templates/order/receive_parts.html +++ b/InvenTree/order/templates/order/receive_parts.html @@ -1,23 +1,28 @@ {% extends "modal_form.html" %} +{% load i18n %} +{% load inventree_extras %} +{% load status_codes %} {% block form %} -Receive outstanding parts for {{ order }} - {{ order.description }} +{% trans "Receive outstanding parts for" %} {{ order }} - {{ order.description }}