diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 72e5dbeeb5..2a1215d7a8 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -3,6 +3,12 @@ --secondary-color: #b69c80; --highlight-color: #f5efe8; --basic-color: #333; + + --label-red: #e35a57; + --label-blue: #4194bd; + --label-green: #50aa51; + --label-grey: #aaa; + --label-yellow: #fdc82a; } .markdownx .row { @@ -158,6 +164,51 @@ padding-bottom: 5px; } +.label-large-red { + color: var(--label-red); + border-color: var(--label-red); +} + +.label-red { + background: var(--label-red); +} + +.label-large-blue { + color: var(--label-blue); + border-color: var(--label-blue); +} + +.label-blue { + background: var(--label-blue); +} + +.label-large-green { + color: var(--label-green); + border-color: var(--label-green); +} + +.label-green { + background: var(--label-green); +} + +.label-large-grey { + color: var(--label-grey); + border-color: var(--label-grey); +} + +.label-grey { + background: var(--label-grey); +} + +.label-large-yellow { + color: var(--label-yellow); + border-color: var(--label-yellow); +} + +.label-yellow { + background: var(--label-yellow); +} + .label-right { float: right; margin-left: 3px; diff --git a/InvenTree/InvenTree/static/script/inventree/order.js b/InvenTree/InvenTree/static/script/inventree/order.js index 7e2b83a406..c4e39d9e1d 100644 --- a/InvenTree/InvenTree/static/script/inventree/order.js +++ b/InvenTree/InvenTree/static/script/inventree/order.js @@ -238,7 +238,12 @@ function loadSalesOrderTable(table, options) { { sortable: true, field: 'creation_date', - title: 'Date', + title: 'Creation Date', + }, + { + sortable: true, + field: 'shipment_date', + title: "Shipment Date", }, { sortable: true, diff --git a/InvenTree/InvenTree/status_codes.py b/InvenTree/InvenTree/status_codes.py index a9f0048867..efb76b86fa 100644 --- a/InvenTree/InvenTree/status_codes.py +++ b/InvenTree/InvenTree/status_codes.py @@ -7,14 +7,6 @@ class StatusCode: This is used to map a set of integer values to text. """ - # Colors used for label rendering - LBL_WHITE = '#FFF' - LBL_GREY = "#AAA" - LBL_GREEN = "#50aa51" - LBL_BLUE = "#4194bd" - LBL_YELLOW = "#fdc82a" - LBL_RED = "#e35a57" - @classmethod def render(cls, key, large=False): """ @@ -26,18 +18,15 @@ class StatusCode: return key value = cls.options.get(key, key) - color = cls.colors.get(key, StatusCode.LBL_GREY) + color = cls.colors.get(key, 'grey') if large: - span_class = 'label label-large' - style = 'color: {c}; border-color: {c}; background: none;'.format(c=color) + span_class = 'label label-large label-large-{c}'.format(c=color) else: - span_class = 'label' - style = 'color: {w}; background: {c}'.format(w=StatusCode.LBL_WHITE, c=color) + span_class = 'label label-{c}'.format(c=color) - return "{value}".format( + return "{value}".format( cl=span_class, - st=style, value=value ) @@ -107,12 +96,12 @@ class PurchaseOrderStatus(StatusCode): } colors = { - PENDING: StatusCode.LBL_BLUE, - PLACED: StatusCode.LBL_BLUE, - COMPLETE: StatusCode.LBL_GREEN, - CANCELLED: StatusCode.LBL_RED, - LOST: StatusCode.LBL_YELLOW, - RETURNED: StatusCode.LBL_YELLOW, + PENDING: 'blue', + PLACED: 'blue', + COMPLETE: 'green', + CANCELLED: 'red', + LOST: 'yellow', + RETURNED: 'yellow', } # Open orders @@ -147,11 +136,11 @@ class SalesOrderStatus(StatusCode): } colors = { - PENDING: StatusCode.LBL_BLUE, - SHIPPED: StatusCode.LBL_GREEN, - CANCELLED: StatusCode.LBL_RED, - LOST: StatusCode.LBL_YELLOW, - RETURNED: StatusCode.LBL_YELLOW, + PENDING: 'blue', + SHIPPED: 'green', + CANCELLED: 'red', + LOST: 'yellow', + RETURNED: 'yellow', } @@ -168,7 +157,7 @@ class StockStatus(StatusCode): # This can be used as a quick check for filtering NOT_IN_STOCK = 100 - SENT_TO_CUSTOMER = 110 # Item has been shipped to a customer + SHIPPED = 110 # Item has been shipped to a customer ASSIGNED_TO_BUILD = 120 ASSIGNED_TO_OTHER_ITEM = 130 @@ -179,13 +168,19 @@ class StockStatus(StatusCode): DESTROYED: _("Destroyed"), LOST: _("Lost"), RETURNED: _("Returned"), + SHIPPED: _('Shipped'), + ASSIGNED_TO_BUILD: _("Used for Build"), + ASSIGNED_TO_OTHER_ITEM: _("Installed in Stock Item") } colors = { - OK: StatusCode.LBL_GREEN, - ATTENTION: StatusCode.LBL_YELLOW, - DAMAGED: StatusCode.LBL_RED, - DESTROYED: StatusCode.LBL_RED, + OK: 'green', + ATTENTION: 'yellow', + DAMAGED: 'red', + DESTROYED: 'red', + SHIPPED: 'green', + ASSIGNED_TO_BUILD: 'blue', + ASSIGNED_TO_OTHER_ITEM: 'blue', } # The following codes correspond to parts that are 'available' or 'in stock' @@ -201,6 +196,8 @@ class StockStatus(StatusCode): DESTROYED, LOST, SHIPPED, + ASSIGNED_TO_BUILD, + ASSIGNED_TO_OTHER_ITEM, ] @@ -220,10 +217,10 @@ class BuildStatus(StatusCode): } colors = { - PENDING: StatusCode.LBL_BLUE, - ALLOCATED: StatusCode.LBL_BLUE, - COMPLETE: StatusCode.LBL_GREEN, - CANCELLED: StatusCode.LBL_RED, + PENDING: 'blue', + ALLOCATED: 'blue', + COMPLETE: 'green', + CANCELLED: 'red', } ACTIVE_CODES = [ diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py index de44f1185c..1c0f91570e 100644 --- a/InvenTree/build/api.py +++ b/InvenTree/build/api.py @@ -38,7 +38,6 @@ class BuildList(generics.ListCreateAPIView): ] filter_fields = [ - 'part', 'sales_order', ] @@ -48,15 +47,25 @@ class BuildList(generics.ListCreateAPIView): as some of the fields don't natively play nicely with DRF """ - build_list = super().get_queryset() + queryset = super().get_queryset().prefetch_related('part') + + return queryset + + def filter_queryset(self, queryset): # Filter by build status? status = self.request.query_params.get('status', None) if status is not None: - build_list = build_list.filter(status=status) + queryset = queryset.filter(status=status) - return build_list + # Filter by associated part? + part = self.request.query_params.get('part', None) + + if part is not None: + queryset = queryset.filter(part=part) + + return queryset def get_serializer(self, *args, **kwargs): diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index beed4457e6..0ca5b33a4b 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -583,6 +583,6 @@ class SalesOrderAllocation(models.Model): # Clear the location item.location = None - item.status = StockStatus.SENT_TO_CUSTOMER + item.status = StockStatus.SHIPPED item.save() diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index 992e05a80c..95ebae34da 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -152,6 +152,7 @@ class SalesOrderSerializer(InvenTreeModelSerializer): 'customer_reference', 'status', 'status_text', + 'shipment_date', 'notes', ] diff --git a/InvenTree/part/templates/part/tabs.html b/InvenTree/part/templates/part/tabs.html index b612106706..e092708a0a 100644 --- a/InvenTree/part/templates/part/tabs.html +++ b/InvenTree/part/templates/part/tabs.html @@ -6,7 +6,7 @@ {% trans "Details" %} - {% trans "Parameters" %} {{ part.parameters.count }} + {% trans "Parameters" %}{{ part.parameters.count }} {% if part.is_template %} @@ -25,7 +25,7 @@ {% trans "BOM" %}{{ part.bom_count }} - {% trans "Build Orders" %}{{ part.active_builds|length }} + {% trans "Build Orders" %}{{ part.builds.count }} {% endif %} {% if part.component or part.used_in_count > 0 %} @@ -60,6 +60,6 @@ {% trans "Attachments" %} {% if part.attachment_count > 0 %}{{ part.attachment_count }}{% endif %} - {% trans "Notes" %}{% if part.notes %} {% endif %} + {% trans "Notes" %}{% if part.notes %} {% endif %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 77023eba35..ae38263001 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -41,7 +41,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% trans "This stock item cannot be deleted as it has child items" %}
-{% elif item.delete_on_deplete %} +{% elif item.delete_on_deplete and item.can_delete %}
{% trans "This stock item will be automatically deleted when all stock is depleted." %}
@@ -59,7 +59,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% endblock %} {% block page_data %} -

{% trans "Stock Item" %}

+

{% trans "Stock Item" %}{% if item.status in StockStatus.UNAVAILABLE_CODES %}{% stock_status_label item.status large=True %}{% endif %}


{% if item.serialized %} @@ -125,6 +125,12 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {% trans "Belongs To" %} {{ item.belongs_to }} + {% elif item.customer %} + + + {% trans "Customer" %} + {{ item.customer.name }} + {% elif item.location %} @@ -173,11 +179,11 @@ InvenTree | {% trans "Stock Item" %} - {{ item }} {{ item.purchase_order }} {% endif %} - {% if item.customer %} + {% if item.parent %} - - {% trans "Customer" %} - {{ item.customer.name }} + + {% trans "Parent Item" %} + {{ item.parent }} {% endif %} {% if item.link %} diff --git a/InvenTree/templates/status_codes.html b/InvenTree/templates/status_codes.html index eb2b4b144d..029252a842 100644 --- a/InvenTree/templates/status_codes.html +++ b/InvenTree/templates/status_codes.html @@ -5,7 +5,7 @@ var {{ label }}Codes = { {% for opt in options %}'{{ opt.key }}': { key: '{{ opt.key }}', value: '{{ opt.value }}',{% if opt.color %} - color: '{{ opt.color }}',{% endif %} + label: 'label-{{ opt.color }}',{% endif %} },{% endfor %} }; @@ -25,7 +25,7 @@ function {{ label }}StatusDisplay(key) { } // Select the label color - var color = {{ label }}Codes[key].color ?? '#AAA'; + var label = {{ label }}Codes[key].label ?? ''; - return `${value}`; + return `${value}`; }