mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Reorganized stock location view
This commit is contained in:
parent
f578f68001
commit
6986709fb8
@ -320,6 +320,11 @@ class StockLocationList(generics.ListCreateAPIView):
|
|||||||
'description',
|
'description',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ordering_fields = [
|
||||||
|
'name',
|
||||||
|
'items',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class StockList(generics.ListCreateAPIView):
|
class StockList(generics.ListCreateAPIView):
|
||||||
""" API endpoint for list view of Stock objects
|
""" API endpoint for list view of Stock objects
|
||||||
|
@ -244,6 +244,7 @@ class LocationSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
items = serializers.IntegerField(source='item_count', read_only=True)
|
items = serializers.IntegerField(source='item_count', read_only=True)
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockLocation
|
model = StockLocation
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -2,8 +2,15 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block menubar %}
|
||||||
|
{% include "stock/location_navbar.html" with tab="stock" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree'>
|
||||||
|
|
||||||
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
{% setting_object 'STOCK_OWNERSHIP_CONTROL' as owner_control %}
|
||||||
{% if owner_control.value == "True" %}
|
{% if owner_control.value == "True" %}
|
||||||
{% authorized_owners location.owner as owners %}
|
{% authorized_owners location.owner as owners %}
|
||||||
@ -120,36 +127,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if location and location.children.all|length > 0 %}
|
{% block location_content %}
|
||||||
{% include 'stock/location_list.html' with children=location.children.all collapse_id="locations" %}
|
|
||||||
{% elif locations|length > 0 %}
|
|
||||||
{% include 'stock/location_list.html' with children=locations collapse_id="locations" %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<hr>
|
<div class='panel panel-default panel-inventree'>
|
||||||
|
<div class='panel-heading'>
|
||||||
{% include "stock_table.html" %}
|
<h4>{% trans "Stock Items" %}</h4>
|
||||||
|
</div>
|
||||||
|
{% include "stock_table.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_load %}
|
</div>
|
||||||
{{ block.super }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
if (inventreeLoadInt("show-part-locs") == 1) {
|
enableNavbar({
|
||||||
$("#collapse-item-locations").collapse('show');
|
label: 'location',
|
||||||
}
|
toggleId: '#location-menu-toggle'
|
||||||
|
|
||||||
$("#collapse-item-locations").on('shown.bs.collapse', function() {
|
|
||||||
inventreeSave('show-part-locs', 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#collapse-item-locations").on('hidden.bs.collapse', function() {
|
|
||||||
inventreeDel('show-part-locs');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
{% if location %}
|
{% if location %}
|
||||||
@ -261,7 +261,7 @@
|
|||||||
],
|
],
|
||||||
params: {
|
params: {
|
||||||
{% if location %}
|
{% if location %}
|
||||||
location: {{ location.id }},
|
location: {{ location.pk }},
|
||||||
{% endif %}
|
{% endif %}
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
location_detail: true,
|
location_detail: true,
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
{% extends "collapse.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% if roles.stock_location.view or roles.stock.view %}
|
|
||||||
{% block collapse_title %}
|
|
||||||
{% trans 'Sub-Locations' %}<span class='badge'>{{ children|length }}</span>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block collapse_content %}
|
|
||||||
<ul class="list-group">
|
|
||||||
{% for child in children %}
|
|
||||||
<li class="list-group-item"><a href="{% url 'stock-location-detail' child.id %}">{{ child.name }}</a> - <i>{{ child.description }}</i>
|
|
||||||
{% if child.item_count > 0 %}
|
|
||||||
<!-- span class='badge'>{{ child.item_count }} Item{% if child.item_count > 1 %}s{% endif %}</span> -->
|
|
||||||
<span class='badge'>
|
|
||||||
{% comment %}Translators: pluralize with counter{% endcomment %}
|
|
||||||
{% blocktrans count counter=child.item_count %}{{ counter }} Item{% plural %}{{ counter }} Items{% endblocktrans %}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endblock %}
|
|
||||||
{% endif %}
|
|
33
InvenTree/stock/templates/stock/location_navbar.html
Normal file
33
InvenTree/stock/templates/stock/location_navbar.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<ul class='list-group'>
|
||||||
|
|
||||||
|
<li class='list-group-item'>
|
||||||
|
<a href='#' id='location-menu-toggle'>
|
||||||
|
<span class='menu-tab-icon fas fa-expand-arrows-alt'></span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class='list-group-item {% if tab == "sublocations" %}active{% endif %}' title='{% trans "Sublocations" %}'>
|
||||||
|
{% if location %}
|
||||||
|
<a href='{% url "stock-location-sublocation" location.id %}'>
|
||||||
|
{% else %}
|
||||||
|
<a href='{% url "stock-sublocations" %}'>
|
||||||
|
{% endif %}
|
||||||
|
<span class='fas fa-sitemap'></span>
|
||||||
|
{% trans "Sublocations" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
|
||||||
|
{% if location %}
|
||||||
|
<a href='{% url "stock-location-detail" location.id %}'>
|
||||||
|
{% else %}
|
||||||
|
<a href='{% url "stock-index" %}'>
|
||||||
|
{% endif %}
|
||||||
|
<span class='fas fa-boxes'></span>
|
||||||
|
{% trans "Stock Items" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
36
InvenTree/stock/templates/stock/sublocation.html
Normal file
36
InvenTree/stock/templates/stock/sublocation.html
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{% extends "stock/location.html" %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load inventree_extras %}
|
||||||
|
|
||||||
|
{% block menubar %}
|
||||||
|
{% include "stock/location_navbar.html" with tab="sublocations" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block location_content %}
|
||||||
|
|
||||||
|
<div class='panel panel-default panel-inventree'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
<h4>{% trans "Sublocations" %}</h4>
|
||||||
|
</div>
|
||||||
|
<table class='table table-striped table-condensed' id='sublocation-table'></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
loadStockLocationTable($('#sublocation-table'), {
|
||||||
|
params: {
|
||||||
|
{% if location %}
|
||||||
|
parent: {{ location.pk }},
|
||||||
|
{% else %}
|
||||||
|
parent: 'null',
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -6,14 +6,21 @@ from django.conf.urls import url, include
|
|||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
# URL list for web interface
|
location_urls = [
|
||||||
stock_location_detail_urls = [
|
|
||||||
|
url(r'^new/', views.StockLocationCreate.as_view(), name='stock-location-create'),
|
||||||
|
|
||||||
|
url(r'^(?P<pk>\d+)/', include([
|
||||||
url(r'^edit/?', views.StockLocationEdit.as_view(), name='stock-location-edit'),
|
url(r'^edit/?', views.StockLocationEdit.as_view(), name='stock-location-edit'),
|
||||||
url(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
|
url(r'^delete/?', views.StockLocationDelete.as_view(), name='stock-location-delete'),
|
||||||
url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
|
url(r'^qr_code/?', views.StockLocationQRCode.as_view(), name='stock-location-qr'),
|
||||||
|
|
||||||
|
url(r'sublocation/', views.StockLocationDetail.as_view(template_name='stock/sublocation.html'), name='stock-location-sublocation'),
|
||||||
|
|
||||||
# Anything else
|
# Anything else
|
||||||
url('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
|
url('^.*$', views.StockLocationDetail.as_view(), name='stock-location-detail'),
|
||||||
|
])),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
stock_item_detail_urls = [
|
stock_item_detail_urls = [
|
||||||
@ -49,9 +56,7 @@ stock_tracking_urls = [
|
|||||||
|
|
||||||
stock_urls = [
|
stock_urls = [
|
||||||
# Stock location
|
# Stock location
|
||||||
url(r'^location/(?P<pk>\d+)/', include(stock_location_detail_urls)),
|
url(r'^location/', include(location_urls)),
|
||||||
|
|
||||||
url(r'^location/new/', views.StockLocationCreate.as_view(), name='stock-location-create'),
|
|
||||||
|
|
||||||
url(r'^item/new/?', views.StockItemCreate.as_view(), name='stock-item-create'),
|
url(r'^item/new/?', views.StockItemCreate.as_view(), name='stock-item-create'),
|
||||||
|
|
||||||
@ -81,5 +86,7 @@ stock_urls = [
|
|||||||
# Individual stock items
|
# Individual stock items
|
||||||
url(r'^item/(?P<pk>\d+)/', include(stock_item_detail_urls)),
|
url(r'^item/(?P<pk>\d+)/', include(stock_item_detail_urls)),
|
||||||
|
|
||||||
|
url(r'^sublocations/', views.StockIndex.as_view(template_name='stock/sublocation.html'), name='stock-sublocations'),
|
||||||
|
|
||||||
url(r'^.*$', views.StockIndex.as_view(), name='stock-index'),
|
url(r'^.*$', views.StockIndex.as_view(), name='stock-index'),
|
||||||
]
|
]
|
||||||
|
@ -897,6 +897,77 @@ function loadStockTable(table, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadStockLocationTable(table, options) {
|
||||||
|
/* Display a table of stock locations */
|
||||||
|
|
||||||
|
var params = options.params || {};
|
||||||
|
|
||||||
|
var filterListElement = options.filterList || '#filter-list-location';
|
||||||
|
|
||||||
|
var filters = {};
|
||||||
|
|
||||||
|
var filterKey = options.filterKey || options.name || 'location';
|
||||||
|
|
||||||
|
if (!options.disableFilters) {
|
||||||
|
filters = loadTableFilters(filterKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
var original = {};
|
||||||
|
|
||||||
|
for (var key in params) {
|
||||||
|
original[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFilterList(filterKey, table, filterListElement);
|
||||||
|
|
||||||
|
for (var key in params) {
|
||||||
|
filters[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
table.inventreeTable({
|
||||||
|
method: 'get',
|
||||||
|
url: options.url || '{% url "api-location-list" %}',
|
||||||
|
queryParams: filters,
|
||||||
|
sidePagination: 'server',
|
||||||
|
name: 'location',
|
||||||
|
original: original,
|
||||||
|
showColumns: true,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
checkbox: true,
|
||||||
|
title: '{% trans "Select" %}',
|
||||||
|
searchable: false,
|
||||||
|
switchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '{% trans "Name" %}',
|
||||||
|
switchable: true,
|
||||||
|
sortable: true,
|
||||||
|
formatter: function(value, row) {
|
||||||
|
return renderLink(
|
||||||
|
value,
|
||||||
|
`/stock/location/${row.pk}/`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'description',
|
||||||
|
title: '{% trans "Description" %}',
|
||||||
|
switchable: true,
|
||||||
|
sortable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'items',
|
||||||
|
title: '{% trans "Stock Items" %}',
|
||||||
|
switchable: true,
|
||||||
|
sortable: false,
|
||||||
|
sortName: 'item_count',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function loadStockTrackingTable(table, options) {
|
function loadStockTrackingTable(table, options) {
|
||||||
|
|
||||||
var cols = [
|
var cols = [
|
||||||
|
Loading…
Reference in New Issue
Block a user