2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 12:36:45 +00:00

Refactor admin button for:

- build order
- part detail
- stock item
- stock location
- company detail
- manufacturer-part
- purchase order
- sales order
This commit is contained in:
Oliver 2021-10-29 17:07:35 +11:00
parent 8afa39cd91
commit b41d1aed12
17 changed files with 586 additions and 541 deletions

View File

@ -23,15 +23,16 @@ src="{% static 'img/blank_image.png' %}"
{% endif %}/>
{% endblock %}
{% block details %}
<h4>
{% block heading %}
{% trans "Build Order" %} {{ build }}
{% endblock %}
{% block actions %}
<!-- Admin Display -->
{% if user.is_staff and roles.build.change %}
<a href="{% url 'admin:build_build_change' build.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% url 'admin:build_build_change' build.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</h4>
<p>{{ build.title }}</p>
<div class='btn-group' role='group'>
<!-- Printing options -->
<div class='btn-group'>
<button id='print-options' title='{% trans "Print actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
@ -59,10 +60,53 @@ src="{% static 'img/blank_image.png' %}"
</div>
{% if build.active %}
<button id='build-complete' title='{% trans "Complete Build" %}' class='btn btn-success'>
<span class='fas fa-check-circle'></span>
<span class='fas fa-check-circle'></span> {% trans "Complete Build" %}
</button>
{% endif %}
{% endif %}
{% endblock %}
{% block details %}
<p>{{ build.title }}</p>
<div class='info-messages'>
{% if build.sales_order %}
<div class='alert alert-block alert-info'>
{% object_link 'so-detail' build.sales_order.id build.sales_order as link %}
{% blocktrans %}This Build Order is allocated to Sales Order {{link}}{% endblocktrans %}
</div>
{% endif %}
{% if build.parent %}
<div class='alert alert-block alert-info'>
{% object_link 'build-detail' build.parent.id build.parent as link %}
{% blocktrans %}This Build Order is a child of Build Order {{link}}{% endblocktrans %}
</div>
{% endif %}
{% if build.active %}
{% if build.can_complete %}
<div class='alert alert-block alert-success'>
{% trans "Build Order is ready to mark as completed" %}
</div>
{% endif %}
{% if build.incomplete_count > 0 %}
<div class='alert alert-block alert-danger'>
{% trans "Build Order cannot be completed as outstanding outputs remain" %}
</div>
{% endif %}
{% if build.completed < build.quantity %}
<div class='alert alert-block alert-warning'>
{% trans "Required build quantity has not yet been completed" %}
</div>
{% endif %}
{% if not build.areUntrackedPartsFullyAllocated %}
<div class='alert alert-block alert-warning'>
{% trans "Stock has not been fully allocated to this Build Order" %}
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}
@ -133,44 +177,6 @@ src="{% static 'img/blank_image.png' %}"
</tr>
{% endif %}
</table>
<div class='info-messages'>
{% if build.sales_order %}
<div class='alert alert-block alert-info'>
{% object_link 'so-detail' build.sales_order.id build.sales_order as link %}
{% blocktrans %}This Build Order is allocated to Sales Order {{link}}{% endblocktrans %}
</div>
{% endif %}
{% if build.parent %}
<div class='alert alert-block alert-info'>
{% object_link 'build-detail' build.parent.id build.parent as link %}
{% blocktrans %}This Build Order is a child of Build Order {{link}}{% endblocktrans %}
</div>
{% endif %}
{% if build.active %}
{% if build.can_complete %}
<div class='alert alert-block alert-success'>
{% trans "Build Order is ready to mark as completed" %}
</div>
{% endif %}
{% if build.incomplete_count > 0 %}
<div class='alert alert-block alert-danger'>
{% trans "Build Order cannot be completed as outstanding outputs remain" %}
</div>
{% endif %}
{% if build.completed < build.quantity %}
<div class='alert alert-block alert-warning'>
{% trans "Required build quantity has not yet been completed" %}
</div>
{% endif %}
{% if not build.areUntrackedPartsFullyAllocated %}
<div class='alert alert-block alert-warning'>
{% trans "Stock has not been fully allocated to this Build Order" %}
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}
{% block page_data %}

View File

@ -8,9 +8,34 @@
{% inventree_title %} | {% trans "Company" %} - {{ company.name }}
{% endblock %}
{% block details_left %}
<div class='row g-0'>
<div class='col-md-4'>
{% block heading %}
{% trans "Company" %}: {{ company.name }}
{% endblock %}
{% block actions %}
<!-- Admin View -->
{% if user.is_staff and perms.company.change_company %}
{% url 'admin:company_company_change' company.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if company.is_supplier and roles.purchase_order.add %}
<button type='button' class='btn btn-outline-secondary' id='company-order-2' title='{% trans "Create Purchase Order" %}'>
<span class='fas fa-shopping-cart'/>
</button>
{% endif %}
{% if perms.company.change_company %}
<button type='button' class='btn btn-outline-secondary' id='company-edit' title='{% trans "Edit company information" %}'>
<span class='fas fa-edit icon-green'/>
</button>
{% endif %}
{% if perms.company.delete_company %}
<button type='button' class='btn btn-outline-secondary' id='company-delete' title='{% trans "Delete Company" %}'>
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
{% endblock %}
{% block thumbnail %}
<div class='dropzone part-thumb-container' id='company-thumb'>
<img class="part-thumb" id='company-image'
{% if company.image %}
@ -28,34 +53,11 @@
</div>
</div>
</div>
</div>
<div class='col-md-8'>
<h4>
{{ company.name }}
{% if user.is_staff and perms.company.change_company %}
<a href="{% url 'admin:company_company_change' company.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
</h4>
{% endblock %}
{% block details %}
<p>{{ company.description }}</p>
<div class='btn-group' role='group'>
{% if company.is_supplier and roles.purchase_order.add %}
<button type='button' class='btn btn-outline-secondary' id='company-order-2' title='{% trans "Create Purchase Order" %}'>
<span class='fas fa-shopping-cart'/>
</button>
{% endif %}
{% if perms.company.change_company %}
<button type='button' class='btn btn-outline-secondary' id='company-edit' title='{% trans "Edit company information" %}'>
<span class='fas fa-edit icon-green'/>
</button>
{% endif %}
{% if perms.company.delete_company %}
<button type='button' class='btn btn-outline-secondary' id='company-delete' title='{% trans "Delete Company" %}'>
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block details_right %}

View File

@ -18,27 +18,18 @@ InvenTree | {% trans "Manufacturer Part" %}
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "manufacturer-part-detail" part.id %}'>{{ part.MPN }}</a></li>
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if part.part.image %}
src='{{ part.part.image.url }}'
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}/>
{% endblock %}
{% block details %}
{% block heading %}
<h4>
{% trans "Manufacturer Part" %}: {{ part.part.full_name }}
{% if user.is_staff and perms.company.change_company %}
<a href="{% url 'admin:company_supplierpart_change' part.pk %}">
<span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span>
</a>
{% endif %}
</h4>
{% endblock %}
{% block actions %}
{% if user.is_staff and perms.company.change_company %}
{% url 'admin:company_supplierpart_change' part.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if roles.purchase_order.change %}
<div class='btn-group' role='group'>
{% comment "for later" %}
{% if roles.purchase_order.add %}
<button type='button' class='btn btn-outline-secondary' id='order-part' title='{% trans "Order part" %}'>
@ -54,8 +45,19 @@ src="{% static 'img/blank_image.png' %}"
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
</div>
{% endif %}
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if part.part.image %}
src='{{ part.part.image.url }}'
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}/>
{% endblock %}
{% block details %}
{% endblock %}

View File

@ -19,31 +19,17 @@
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "supplier-part-detail" part.id %}'>{{ part.SKU }}</a></li>
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if part.part.image %}
src='{{ part.part.image.url }}'
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}/>
{% endblock %}
{% block details %}
{% block heading %}
<h4>
{% trans "Supplier Part" %}: {{ part.SKU }}
{% if user.is_staff and perms.company.change_company %}
<a href="{% url 'admin:company_supplierpart_change' part.pk %}">
<span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span>
</a>
{% endif %}
</h4>
<p>
{{ part.part.full_name }}
</p>
{% endblock %}
{% if roles.purchase_order.change %}
<div class='btn-row'>
<div class='btn-group' role='group'>
{% block actions %}
{% if user.is_staff and perms.company.change_company %}
{% url 'admin:company_supplierpart_change' part.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if roles.purchase_order.add %}
<button type='button' class='btn btn-outline-secondary' id='order-part' title='{% trans "Order part" %}'>
<span class='fas fa-shopping-cart'></span>
@ -57,9 +43,22 @@ src="{% static 'img/blank_image.png' %}"
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if part.part.image %}
src='{{ part.part.image.url }}'
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}/>
{% endblock %}
{% block details %}
<p>
{{ part.part.full_name }}
</p>
{% endblock %}

View File

@ -14,31 +14,15 @@
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "po-detail" order.id %}'>{{ order }}</a></li>
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if order.supplier.image %}
src="{{ order.supplier.image.url }}"
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}
/>
{% block heading %}
{% trans "Purchase Order" %}: {{ order.reference }}
{% endblock %}
{% block details %}
<h4>
{% trans "Purchase Order" %}: {{ order.reference }}
{% block actions %}
{% if user.is_staff and roles.purchase_order.change %}
<a href="{% url 'admin:order_purchaseorder_change' order.pk %}"><span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span></a>
{% url 'admin:order_purchaseorder_change' order.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</h4>
<h4>
{% purchase_order_status_label order.status large=True %}
{% if order.is_overdue %}
<span class='badge rounded-pill bg-danger'>{% trans "Overdue" %}</span>
{% endif %}
</h4>
<p>{{ order.description }}{% include "clip.html"%}</p>
<div class='btn-group' role='group'>
<!-- Printing options -->
<div class='btn-group' role='group'>
<button id='print-options' title='{% trans "Print actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
@ -75,7 +59,28 @@ src="{% static 'img/blank_image.png' %}"
</button>
{% endif %}
{% endif %}
</div>
{% endblock %}
{% block thumbnail %}
<img class='part-thumb'
{% if order.supplier.image %}
src="{{ order.supplier.image.url }}"
{% else %}
src="{% static 'img/blank_image.png' %}"
{% endif %}
/>
{% endblock %}
{% block details %}
<h4>
{% purchase_order_status_label order.status large=True %}
{% if order.is_overdue %}
<span class='badge rounded-pill bg-danger'>{% trans "Overdue" %}</span>
{% endif %}
</h4>
<p>{{ order.description }}{% include "clip.html"%}</p>
{% endblock %}
{% block details_right %}

View File

@ -24,22 +24,15 @@ src="{% static 'img/blank_image.png' %}"
/>
{% endblock %}
{% block details %}
<h4>
{% block heading %}
{% trans "Sales Order" %} {{ order.reference }}
{% endblock %}
{% block actions %}
{% if user.is_staff and roles.sales_order.change %}
<a href="{% url 'admin:order_salesorder_change' order.pk %}"><span title='{% trans "Admin view" %}' class='fas fa-user-shield'></span></a>
{% url 'admin:order_salesorder_change' order.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</h4>
<h4>
{% sales_order_status_label order.status large=True %}
{% if order.is_overdue %}
<span class='badge rounded-pill bg-danger'>{% trans "Overdue" %}</span>
{% endif %}
</h4>
<p>{{ order.description }}{% include "clip.html"%}</p>
<div class='btn-group' role='group'>
<!-- Printing actions -->
<div class='btn-group' role='group'>
<button id='print-options' title='{% trans "Print actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'>
@ -68,13 +61,23 @@ src="{% static 'img/blank_image.png' %}"
</div>
{% if order.status == SalesOrderStatus.PENDING %}
<button type='button' class='btn btn-outline-secondary' id='ship-order' title='{% trans "Ship order" %}'>
<span class='fas fa-truck icon-blue'></span>
<button type='button' class='btn btn-success' id='ship-order' title='{% trans "Ship Order" %}'>
<span class='fas fa-truck'></span> {% trans "Ship Order" %}
</button>
{% endif %}
{% endif %}
</div>
{% block below_thumbnail %}
{% endblock %}
{% block details %}
<h4>
{% sales_order_status_label order.status large=True %}
{% if order.is_overdue %}
<span class='badge rounded-pill bg-danger'>{% trans "Overdue" %}</span>
{% endif %}
</h4>
<p>{{ order.description }}{% include "clip.html"%}</p>
<div class='info-messages'>
{% if order.status == SalesOrderStatus.PENDING and not order.is_fully_allocated %}
<div class='alert alert-block alert-danger'>
@ -82,7 +85,7 @@ src="{% static 'img/blank_image.png' %}"
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
{% block details_right %}

View File

@ -1,6 +1,5 @@
{% load i18n %}
<li><a href='#' id='toggle-part-tree'><strong><span class='fas fa-stream'></span></strong></a></li>
<li class="breadcrumb-item{% if category is None %} active" aria-current="page{% endif %}"><a href="/part/">{% trans "Parts" %}</a></li>
{% if category %}
{% for path_item in category.parentpath %}

View File

@ -6,32 +6,23 @@
{% include 'part/category_sidebar.html' %}
{% endblock %}
{% block details_left %}
{% block heading %}
{% if category %}
<h4>
{% trans "Part Category" %}: {{ category.name }}
{% if user.is_staff and roles.part_category.change %}
<a href="{% url 'admin:part_partcategory_change' category.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
</h4>
<p>{{ category.description }}</p>
{% else %}
<h4>
{% trans "Parts" %}
</h4>
<p>{% trans "Top level part category" %}</p>
{% endif %}
{% endblock %}
<div class='btn-group' role='group'>
{% if roles.part_category.add %}
<button class='btn btn-success' id='cat-create' title='{% trans "Create new part category" %}'>
<span class='fas fa-plus-circle icon-green'/>
</button>
{% block actions %}
{% if user.is_staff and roles.part_category.change %}
{% url 'admin:part_partcategory_change' category.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if category %}
{% if roles.part_category.change %}
<button class='btn btn-outline-secondary' id='cat-edit' title='{% trans "Edit part category" %}'>
<span class='fas fa-edit icon-blue'/>
<span class='fas fa-edit'/>
</button>
{% endif %}
{% if roles.part_category.delete %}
@ -40,7 +31,19 @@
</button>
{% endif %}
{% endif %}
</div>
{% if roles.part_category.add %}
<button class='btn btn-success' id='cat-create' title='{% trans "Create new part category" %}'>
<span class='fas fa-plus-circle'></span> {% trans "Add Category" %}
</button>
{% endif %}
{% endblock %}
{% block details_left %}
{% if category %}
<p>{{ category.description }}</p>
{% else %}
<p>{% trans "Top level part category" %}</p>
{% endif %}
{% endblock %}

View File

@ -6,7 +6,7 @@
{% load markdownify %}
{% block sidebar %}
{% include 'part/sidebar.html' %}
{% include 'part/part_sidebar.html' %}
{% endblock %}
{% block page_content %}

View File

@ -12,63 +12,17 @@
{% include "part/part_thumb.html" %}
{% endblock %}
{% block details %}
<h4>
{% block heading %}
{{ part.full_name }}
{% endblock %}
{% block actions %}
<!-- Admin View -->
{% if user.is_staff and roles.part.change %}
<a href="{% url 'admin:part_part_change' part.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>&ensp;
{% url 'admin:part_part_change' part.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</h4>
<!-- Properties -->
<h4>
<div id='part-properties' class='btn-group'>
{% if part.is_template %}
&ensp;
<span class='fas fa-clone' title='{% trans "Part is a template part (variants can be made from this part)" %}'></span>
{% endif %}
{% if part.assembly %}
&ensp;
<span class='fas fa-tools' title='{% trans "Part can be assembled from other parts" %}'></span>
{% endif %}
{% if part.component %}
&ensp;
<span class='fas fa-th' title='{% trans "Part can be used in assemblies" %}'></span>
{% endif %}
{% if part.trackable %}
&ensp;
<span class='fas fa-directions' title='{% trans "Part stock is tracked by serial number" %}'></span>
{% endif %}
{% if part.purchaseable %}
&ensp;
<span class='fas fa-shopping-cart' title='{% trans "Part can be purchased from external suppliers" %}'></span>
{% endif %}
{% if part.salable %}
&ensp;
<span class='fas fa-dollar-sign' title='{% trans "Part can be sold to customers" %}'></span>
{% endif %}
<!-- Part active -->
{% if not part.active %}
&ensp;
<div class='badge rounded-pill bg-danger'>
<span class='fas fa-skull-crossbones' title='{% trans "Part is virtual (not a physical part)" %}'></span>
{% trans 'Inactive' %}
</div>
{% endif %}
<!-- Part virtual -->
{% if part.virtual and part.active %}
&ensp;
<div class='badge rounded-pill bg-warning'>
<span class='fas fa-ghost' title='{% trans "Part is virtual (not a physical part)" %}'></span>
{% trans 'Virtual' %}
</div>
{% endif %}
</div>
</h4>
<!-- Part Actions -->
<div class='btn-group' role='group'>
<button type='button' class='btn btn-outline-secondary' id='toggle-starred' title='{% trans "Star this part" %}'>
<span id='part-star-icon' class='fas fa-star {% if starred %}icon-yellow{% endif %}'/>
</button>
@ -131,8 +85,59 @@
</ul>
</div>
{% endif %}
{% endblock %}
{% block details %}
</h4>
<!-- Properties -->
<h4>
<div id='part-properties' class='btn-group'>
{% if part.is_template %}
&ensp;
<span class='fas fa-clone' title='{% trans "Part is a template part (variants can be made from this part)" %}'></span>
{% endif %}
{% if part.assembly %}
&ensp;
<span class='fas fa-tools' title='{% trans "Part can be assembled from other parts" %}'></span>
{% endif %}
{% if part.component %}
&ensp;
<span class='fas fa-th' title='{% trans "Part can be used in assemblies" %}'></span>
{% endif %}
{% if part.trackable %}
&ensp;
<span class='fas fa-directions' title='{% trans "Part stock is tracked by serial number" %}'></span>
{% endif %}
{% if part.purchaseable %}
&ensp;
<span class='fas fa-shopping-cart' title='{% trans "Part can be purchased from external suppliers" %}'></span>
{% endif %}
{% if part.salable %}
&ensp;
<span class='fas fa-dollar-sign' title='{% trans "Part can be sold to customers" %}'></span>
{% endif %}
<!-- Part active -->
{% if not part.active %}
&ensp;
<div class='badge rounded-pill bg-danger'>
<span class='fas fa-skull-crossbones' title='{% trans "Part is virtual (not a physical part)" %}'></span>
{% trans 'Inactive' %}
</div>
{% endif %}
<!-- Part virtual -->
{% if part.virtual and part.active %}
&ensp;
<div class='badge rounded-pill bg-warning'>
<span class='fas fa-ghost' title='{% trans "Part is virtual (not a physical part)" %}'></span>
{% trans 'Virtual' %}
</div>
{% endif %}
</div>
</h4>
<!-- Part info messages -->
<div class='info-messages'>

View File

@ -4,7 +4,7 @@
{% decimal total_stock %}
{% if total_stock == 0 %}
<span class='badge rounded-pill bg-danger'>{% trans "No Stock" %}</span>
<span class='badge badge-right rounded-pill bg-danger'>{% trans "No Stock" %}</span>
{% elif total_stock < part.minimum_stock %}
<span class='badge rounded-pill bg-warning'>{% trans "Low Stock" %}</span>
<span class='badge badge-right rounded-pill bg-warning'>{% trans "Low Stock" %}</span>
{% endif %}

View File

@ -13,54 +13,15 @@
{% endblock %}
{% block heading %}
<h4>
{% trans "Stock Item Details" %}
</h4>
{% trans "Stock Item" %}: {{ item.part.full_name}}
{% endblock %}
{% block thumbnail %}
<img class='part-thumb' {% if item.part.image %}src="{{ item.part.image.url }}"{% else %}src="{% static 'img/blank_image.png' %}"{% endif %}/>
{% endblock %}
{% block actions %}
{% block details %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners item.owner as owners %}
{% endif %}
<h4>
{{ item.part.full_name}}
{% if roles.part.view %}
{% endif %}
{% if item.serialized %}
# {{ item.serial }}
{% else %}
&times {% decimal item.quantity %}
{% endif %}
{% if user.is_staff and roles.stock.change %}
<a href="{% url 'admin:stock_stockitem_change' item.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% url 'admin:stock_stockitem_change' item.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</h4>
<h4>
{% if item.is_expired %}
<span class='badge rounded-pill bg-danger'>{% trans "Expired" %}</span>
{% else %}
{% if roles.stock.change %}
<a href='#' id='stock-edit-status'>
{% endif %}
{% stock_status_label item.status large=True %}
{% if roles.stock.change %}
</a>
{% endif %}
{% if item.is_stale %}
<span class='badge rounded-pill bg-warning'>{% trans "Stale" %}</span>
{% endif %}
{% endif %}
</h4>
<div class='btn-group' role='group'>
{% if barcodes %}
<!-- Barcode actions menu -->
<div class='btn-group' role='group'>
@ -151,7 +112,37 @@
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}
{% block thumbnail %}
<img class='part-thumb' {% if item.part.image %}src="{{ item.part.image.url }}"{% else %}src="{% static 'img/blank_image.png' %}"{% endif %}/>
{% endblock %}
{% block details %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}
{% authorized_owners item.owner as owners %}
{% endif %}
<h4>
{% if item.is_expired %}
<span class='badge rounded-pill bg-danger'>{% trans "Expired" %}</span>
{% else %}
{% if roles.stock.change %}
<a href='#' id='stock-edit-status'>
{% endif %}
{% stock_status_label item.status large=True %}
{% if roles.stock.change %}
</a>
{% endif %}
{% if item.is_stale %}
<span class='badge rounded-pill bg-warning'>{% trans "Stale" %}</span>
{% endif %}
{% endif %}
</h4>
<div class='info-messages'>

View File

@ -1,6 +1,5 @@
{% load i18n %}
<li><a href='#' title='Toggle Stock Tree' id='toggle-stock-tree'><strong><span class='fas fa-stream'></span></strong></a></li>
<li class="breadcrumb-item{% if location is None %} active" aria-current="page{% endif %}"><a href="/stock/">{% trans "Stock" %}</a></li>
{% if location %}
{% for path_item in location.parentpath %}

View File

@ -7,30 +7,21 @@
{% include "stock/location_sidebar.html" %}
{% endblock %}
{% block details_left %}
{% block heading %}
{% if location %}
<h4>
{% trans "Stock Location" %}: {{ location.name }}
{% if user.is_staff and roles.stock_location.change %}
<a href="{% url 'admin:stock_stocklocation_change' location.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
</h4>
<p>{{ location.description }}</p>
{% else %}
<h4>
{% trans "Stock" %}
</h4>
<p>{% trans "Top level stock location" %}</p>
{% endif %}
{% endblock %}
{% block actions %}
<!-- Admin view -->
{% if location and user.is_staff and roles.stock_location.change %}
{% url 'admin:stock_stocklocation_change' location.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
<div class='btn-group' role='group'>
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %}
{% if roles.stock_location.add %}
<button class='btn btn-success' id='location-create' type='button' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle'></span>
</button>
{% endif %}
{% endif %}
{% if barcodes %}
<!-- Barcode actions menu -->
{% if location %}
@ -79,7 +70,21 @@
{% endif %}
{% endif %}
{% endif %}
</div>
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser or not location %}
{% if roles.stock_location.add %}
<button class='btn btn-success' id='location-create' type='button' title='{% trans "Create new stock location" %}'>
<span class='fas fa-plus-circle'></span> {% trans "New Location" %}
</button>
{% endif %}
{% endif %}
{% endblock %}
{% block details_left %}
{% if location %}
<p>{{ location.description }}</p>
{% else %}
<p>{% trans "Top level stock location" %}</p>
{% endif %}
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
{% if owner_control.value == "True" %}

View File

@ -0,0 +1,4 @@
{% load i18n %}
<button id='admin-button' title='{% trans "View in administration panel" %}' type='button' class='btn btn-primary' url='{{ url }}'>
<span class='fas fa-user-shield'></span>
</button>

View File

@ -190,6 +190,13 @@ function inventreeDocReady() {
$('.brand-icon').each(function(i, obj) {
loadBrandIcon($(this), $(this).attr('brand_name'));
});
// Callback for "admin view" button
$('#admin-button').click(function() {
var url = $(this).attr('url');
location.href = url;
});
}
function isFileTransfer(transfer) {

View File

@ -6,6 +6,21 @@
{% block content %}
<div class='panel'>
<div class='panel-heading'>
<div class='d-flex flex-row'>
<h4>
{% block heading %}
<i>-- page header goes here --</i>
{% endblock %}
</h4>
<span class='flex' style='flex-grow: 1;'></span>
<div id='page-actions' class='btn-group' role='group'>
{% block actions %}
<i>-- actions go here --</i>
{% endblock %}
</div>
</div>
</div>
<div class='panel-content'>
<div class='row'>
<div class='col-sm-6' id='detail-panel-left'>