From 2d2ad91545477a7186ca6b46c8cbe0a888f96a4d Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 15 Jul 2021 12:52:36 +1000 Subject: [PATCH] Move "stock" part view --- .../order/purchase_order_detail.html | 3 +- .../templates/order/sales_order_detail.html | 2 +- InvenTree/part/templates/part/detail.html | 160 +++++++++++------- InvenTree/part/templates/part/navbar.html | 76 +++++---- InvenTree/part/templates/part/part_base.html | 25 +-- InvenTree/part/templates/part/stock.html | 77 --------- InvenTree/part/urls.py | 1 - .../stock/templates/stock/item_base.html | 4 +- 8 files changed, 150 insertions(+), 198 deletions(-) delete mode 100644 InvenTree/part/templates/part/stock.html diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 8832974510..8c9feab452 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -7,8 +7,7 @@ {% load markdownify %} {% block menubar %} -{% include 'order/po_navbar.html' with tab='details' %} - +{% include 'order/po_navbar.html' %} {% endblock %} {% block page_content %} diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index a61f6a11ce..8ada362092 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -7,7 +7,7 @@ {% load markdownify %} {% block menubar %} -{% include "order/so_navbar.html" with tab='details' %} +{% include "order/so_navbar.html" %} {% endblock %} {% block page_content %} diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index ecfddf66c5..c24690c868 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -5,84 +5,70 @@ {% block menubar %} -{% include 'part/navbar.html' with tab='details' %} +{% include 'part/navbar.html' %} {% endblock %} -{% block heading %} -{% trans "Part Details" %} -{% endblock %} +{% block page_content %} -{% block details %} +
+
+

{% trans "Part Stock" %}

+
+
+ {% if part.is_template %} +
+ {% blocktrans with full_name=part.full_name%}Showing stock for all variants of {{full_name}}{% endblocktrans %} +
+ {% endif %} + {% include "stock_table.html" %} +
+
-
-
- - - - - - - - - - - - -
- {% trans "Notes" %} - +
+
+
+
+

{% trans "Notes" %}

+
+
-
- {% if part.notes %} -
- {{ part.notes | markdownify }} -
- {% endif %} -
+
+
-
- +
+ {{ part.notes | markdownify }}
-{% endblock %} - -{% block post_content_panel %} - -
-
-
-
-

{% trans "Parameters" %}

-
-
-
-
- {% if roles.part.add %} - - {% endif %} -
-
-
-
-
+
+
+

{% trans "Parameters" %}

-
-
-
-

{% trans "Attachments" %}

-
-
- {% include "attachment_table.html" %} +
+
+
+ {% if roles.part.add %} + + {% endif %}
+
+
+
+ +
+
+

{% trans "Attachments" %}

+
+
+ {% include "attachment_table.html" %}
@@ -95,6 +81,53 @@ {% block js_ready %} {{ block.super }} + $('#add-stock-item').click(function () { + createNewStockItem({ + reload: true, + data: { + part: {{ part.id }}, + } + }); + }); + + loadStockTable($("#stock-table"), { + params: { + part: {{ part.id }}, + location_detail: true, + part_detail: true, + supplier_part_detail: true, + }, + groupByField: 'location', + buttons: [ + '#stock-options', + ], + url: "{% url 'api-stock-list' %}", + }); + + $("#stock-export").click(function() { + launchModalForm("{% url 'stock-export-options' %}", { + submit_text: "{% trans 'Export' %}", + success: function(response) { + var url = "{% url 'stock-export' %}"; + + url += "?format=" + response.format; + url += "&cascade=" + response.cascade; + url += "&part={{ part.id }}"; + + location.href = url; + }, + }); + }); + + $('#item-create').click(function () { + createNewStockItem({ + reload: true, + data: { + part: {{ part.id }}, + } + }); + }); + $('#edit-notes').click(function() { constructForm('{% url "api-part-detail" part.pk %}', { fields: { @@ -239,4 +272,9 @@ ) }); + attachNavCallbacks({ + name: 'part', + default: 'part-stock' + }); + {% endblock %} diff --git a/InvenTree/part/templates/part/navbar.html b/InvenTree/part/templates/part/navbar.html index e8617dc677..d634229500 100644 --- a/InvenTree/part/templates/part/navbar.html +++ b/InvenTree/part/templates/part/navbar.html @@ -11,46 +11,44 @@ -
  • - - - - {% trans "Details" %} - +
  • + + + {% trans "Parameters" %}
  • {% if part.is_template %} -
  • - +
  • + {% trans "Variants" %}
  • {% endif %} -
  • - +
  • + {% trans "Stock" %}
  • {% if part.component or part.salable %} -
  • - +
  • + {% trans "Allocations" %}
  • {% endif %} {% if part.assembly %} -
  • - +
  • + {% trans "Bill of Materials" %}
  • {% if roles.build.view %} -
  • - +
  • + {% trans "Build Orders" %} @@ -58,55 +56,73 @@ {% endif %} {% endif %} {% if part.component %} -
  • - +
  • + {% trans "Used In" %}
  • {% endif %} -
  • - +
  • + {% trans "Prices" %}
  • {% if part.purchaseable and roles.purchase_order.view %} -
  • - +
  • + {% trans "Suppliers" %}
  • -
  • - +
  • + + + {% trans "Manufacturers" %} + +
  • +
  • + {% trans "Purchase Orders" %}
  • {% endif %} {% if roles.sales_order.view %} -
  • - +
  • + {% trans "Sales Orders" %}
  • {% endif %} {% if part.trackable %} -
  • - +
  • + {% trans "Test Templates" %}
  • {% endif %} {% if show_related %} -
  • - +
  • + {% trans "Related Parts" %}
  • {% endif %} +
  • + + + {% trans "Attachments" %} + +
  • +
  • + + + {% trans "Notes" %} + +
  • diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 2fdcbb278b..e7ec892628 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -245,30 +245,7 @@
    -{% block pre_content_panel %} - -{% endblock %} - -
    - - -
    -

    - {% block heading %} - - {% endblock %} -

    -
    - -
    - {% block details %} - - {% endblock %} -
    - -
    -{% block post_content_panel %} - +{% block page_content %} {% endblock %} {% endblock %} diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html deleted file mode 100644 index ea745708dd..0000000000 --- a/InvenTree/part/templates/part/stock.html +++ /dev/null @@ -1,77 +0,0 @@ -{% extends "part/part_base.html" %} -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include 'part/navbar.html' with tab='stock' %} -{% endblock %} - -{% block heading %} -{% trans "Part Stock" %} -{% endblock %} - -{% block details %} -{% if part.is_template %} -
    - {% blocktrans with full_name=part.full_name%}Showing stock for all variants of {{full_name}}{% endblocktrans %} -
    -{% endif %} - -{% include "stock_table.html" %} - -{% endblock %} - -{% block js_load %} -{{ block.super }} -{% endblock %} -{% block js_ready %} -{{ block.super }} - - $('#add-stock-item').click(function () { - createNewStockItem({ - reload: true, - data: { - part: {{ part.id }}, - } - }); - }); - - loadStockTable($("#stock-table"), { - params: { - part: {{ part.id }}, - location_detail: true, - part_detail: true, - supplier_part_detail: true, - }, - groupByField: 'location', - buttons: [ - '#stock-options', - ], - url: "{% url 'api-stock-list' %}", - }); - - $("#stock-export").click(function() { - launchModalForm("{% url 'stock-export-options' %}", { - submit_text: "{% trans 'Export' %}", - success: function(response) { - var url = "{% url 'stock-export' %}"; - - url += "?format=" + response.format; - url += "&cascade=" + response.cascade; - url += "&part={{ part.id }}"; - - location.href = url; - }, - }); - }); - - $('#item-create').click(function () { - createNewStockItem({ - reload: true, - data: { - part: {{ part.id }}, - } - }); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index 1fa7227f5e..8248d7575a 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -49,7 +49,6 @@ part_detail_urls = [ url(r'^bom-duplicate/?', views.BomDuplicate.as_view(), name='duplicate-bom'), url(r'^variants/?', views.PartDetail.as_view(template_name='part/variants.html'), name='part-variants'), - url(r'^stock/?', views.PartDetail.as_view(template_name='part/stock.html'), name='part-stock'), url(r'^allocation/?', views.PartDetail.as_view(template_name='part/allocation.html'), name='part-allocation'), url(r'^bom/?', views.PartDetail.as_view(template_name='part/bom.html'), name='part-bom'), url(r'^build/?', views.PartDetail.as_view(template_name='part/build.html'), name='part-build'), diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 979c54ba28..ea57b981d8 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -235,7 +235,7 @@ {% trans "Base Part" %} {% if roles.part.view %} - + {% endif %} {{ item.part.full_name }} {% if roles.part.view %} @@ -561,7 +561,7 @@ $("#stock-delete").click(function () { launchModalForm( "{% url 'stock-item-delete' item.id %}", { - redirect: "{% url 'part-stock' item.part.id %}" + redirect: "{% url 'part-detail' item.part.id %}" } ); });