2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

Merged master

This commit is contained in:
eeintech
2021-01-07 13:50:29 -05:00
145 changed files with 23900 additions and 2396 deletions

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-calendar-times icon-header'></span>
{% trans "Expired Stock" %}<span class='badge' id='expired-stock-count'><span class='fas fa-spin fa-spinner'></span></span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='expired-stock-table'>
</table>
{% endblock %}

View File

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block page_title %}
InvenTree | {% trans "Index" %}
{% endblock %}
@ -8,7 +9,7 @@ InvenTree | {% trans "Index" %}
<h3>InvenTree</h3>
<hr>
<div class='col-sm-6'>
<div class='col-sm-4'>
{% if roles.part.view %}
{% include "InvenTree/latest_parts.html" with collapse_id="latest_parts" %}
{% include "InvenTree/bom_invalid.html" with collapse_id="bom_invalid" %}
@ -19,11 +20,18 @@ InvenTree | {% trans "Index" %}
{% include "InvenTree/build_overdue.html" with collapse_id="build_overdue" %}
{% endif %}
</div>
<div class='col-sm-6'>
<div class='col-sm-4'>
{% if roles.stock.view %}
{% include "InvenTree/low_stock.html" with collapse_id="order" %}
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
{% if expiry %}
{% include "InvenTree/expired_stock.html" with collapse_id="expired" %}
{% include "InvenTree/stale_stock.html" with collapse_id="stale" %}
{% endif %}
{% include "InvenTree/required_stock_build.html" with collapse_id="stock_to_build" %}
{% endif %}
</div>
<div class='col-sm-4'>
{% if roles.purchase_order.view %}
{% include "InvenTree/po_outstanding.html" with collapse_id="po_outstanding" %}
{% endif %}
@ -83,6 +91,23 @@ loadBuildTable("#build-overdue-table", {
disableFilters: true,
});
loadStockTable($("#expired-stock-table"), {
params: {
expired: true,
location_detail: true,
part_detail: true,
},
});
loadStockTable($("#stale-stock-table"), {
params: {
stale: true,
expired: false,
location_detail: true,
part_detail: true,
},
});
loadSimplePartTable("#low-stock-table", "{% url 'api-part-list' %}", {
params: {
low_stock: true,
@ -121,64 +146,19 @@ loadSalesOrderTable("#so-overdue-table", {
}
});
$("#latest-parts-table").on('load-success.bs.table', function() {
var count = $("#latest-parts-table").bootstrapTable('getData').length;
{% include "InvenTree/index/on_load.html" with label="latest-parts" %}
{% include "InvenTree/index/on_load.html" with label="starred-parts" %}
{% include "InvenTree/index/on_load.html" with label="bom-invalid" %}
{% include "InvenTree/index/on_load.html" with label="build-pending" %}
{% include "InvenTree/index/on_load.html" with label="build-overdue" %}
$("#latest-parts-count").html(count);
});
{% include "InvenTree/index/on_load.html" with label="expired-stock" %}
{% include "InvenTree/index/on_load.html" with label="stale-stock" %}
{% include "InvenTree/index/on_load.html" with label="low-stock" %}
{% include "InvenTree/index/on_load.html" with label="stock-to-build" %}
$("#starred-parts-table").on('load-success.bs.table', function() {
var count = $("#starred-parts-table").bootstrapTable('getData').length;
$("#starred-parts-count").html(count);
});
$("#bom-invalid-table").on('load-success.bs.table', function() {
var count = $("#bom-invalid-table").bootstrapTable('getData').length;
$("#bom-invalid-count").html(count);
});
$("#build-pending-table").on('load-success.bs.table', function() {
var count = $("#build-pending-table").bootstrapTable('getData').length;
$("#build-pending-count").html(count);
});
$("#build-overdue-table").on('load-success.bs.table', function() {
var count = $("#build-overdue-table").bootstrapTable('getData').length;
$("#build-overdue-count").html(count);
});
$("#low-stock-table").on('load-success.bs.table', function() {
var count = $("#low-stock-table").bootstrapTable('getData').length;
$("#low-stock-count").html(count);
});
$("#stock-to-build-table").on('load-success.bs.table', function() {
var count = $("#stock-to-build-table").bootstrapTable('getData').length;
$("#stock-to-build-count").html(count);
});
$("#po-outstanding-table").on('load-success.bs.table', function() {
var count = $("#po-outstanding-table").bootstrapTable('getData').length;
$("#po-outstanding-count").html(count);
});
$("#so-outstanding-table").on('load-success.bs.table', function() {
var count = $("#so-outstanding-table").bootstrapTable('getData').length;
$("#so-outstanding-count").html(count);
});
$("#so-overdue-table").on('load-success.bs.table', function() {
var count = $("#so-overdue-table").bootstrapTable('getData').length;
$("#so-overdue-count").html(count);
});
{% include "InvenTree/index/on_load.html" with label="po-outstanding" %}
{% include "InvenTree/index/on_load.html" with label="so-outstanding" %}
{% include "InvenTree/index/on_load.html" with label="so-overdue" %}
{% endblock %}

View File

@ -0,0 +1,5 @@
$("#{{ label }}-table").on('load-success.bs.table', function() {
var count = $("#{{ label }}-table").bootstrapTable('getData').length;
$("#{{ label }}-count").html(count);
});

View File

@ -13,7 +13,7 @@
{% block settings %}
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="BUILDORDER_REFERENCE_PREFIX" %}
{% include "InvenTree/settings/setting.html" with key="BUILDORDER_REFERENCE_REGEX" %}

View File

@ -13,11 +13,11 @@
{% block settings %}
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_COMPANY_NAME" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_DEFAULT_CURRENCY" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_INSTANCE" icon="fa-info-circle" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_COMPANY_NAME" icon="fa-building" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_DEFAULT_CURRENCY" icon="fa-dollar-sign" %}
</tbody>
</table>

View File

@ -0,0 +1,12 @@
{% load i18n %}
<col width='25'>
<thead>
<tr>
<th></th>
<th>{% trans "Setting" %}</th>
<th>{% trans "Value" %}</th>
<th>{% trans "Description" %}</th>
<th></th>
</tr>
</thead>

View File

@ -14,16 +14,19 @@
<h4>{% trans "Part Options" %}</h4>
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="PART_IPN_REGEX" %}
{% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %}
<tr><td colspan='4'></td></tr>
{% include "InvenTree/settings/setting.html" with key="PART_COMPONENT" %}
{% include "InvenTree/settings/setting.html" with key="PART_PURCHASEABLE" %}
{% include "InvenTree/settings/setting.html" with key="PART_SALABLE" %}
{% include "InvenTree/settings/setting.html" with key="PART_TRACKABLE" %}
<tr><td colspan='4'></td></tr>
<tr><td colspan='5 '></td></tr>
{% include "InvenTree/settings/setting.html" with key="PART_TEMPLATE" icon="fa-clone" %}
{% include "InvenTree/settings/setting.html" with key="PART_ASSEMBLY" icon="fa-tools" %}
{% include "InvenTree/settings/setting.html" with key="PART_COMPONENT" icon="fa-th"%}
{% include "InvenTree/settings/setting.html" with key="PART_TRACKABLE" icon="fa-directions" %}
{% include "InvenTree/settings/setting.html" with key="PART_PURCHASEABLE" icon="fa-shopping-cart" %}
{% include "InvenTree/settings/setting.html" with key="PART_SALABLE" icon="fa-dollar-sign" %}
{% include "InvenTree/settings/setting.html" with key="PART_VIRTUAL" icon="fa-ghost" %}
<tr><td colspan='5'></td></tr>
{% include "InvenTree/settings/setting.html" with key="PART_COPY_BOM" %}
{% include "InvenTree/settings/setting.html" with key="PART_COPY_PARAMETERS" %}
{% include "InvenTree/settings/setting.html" with key="PART_COPY_TESTS" %}

View File

@ -11,7 +11,7 @@
{% block settings %}
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="PURCHASEORDER_REFERENCE_PREFIX" %}
</tbody>

View File

@ -3,6 +3,11 @@
{% setting_object key as setting %}
<tr>
<td>
{% if icon %}
<span class='fas {{ icon }}'></span>
{% endif %}
</td>
<td><b>{{ setting.name }}</b></td>
<td>
{% if setting.is_bool %}
@ -11,7 +16,9 @@
</div>
{% else %}
{% if setting.value %}
<b>{{ setting.value }}</b>{{ setting.units }}</td>
<i><b>
{{ setting.value }}</b> {{ setting.units }}
</i>
{% else %}
<i>{% trans "No value set" %}</i>
{% endif %}

View File

@ -12,7 +12,7 @@
{% block settings %}
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="SALESORDER_REFERENCE_PREFIX" %}
</tbody>

View File

@ -10,14 +10,16 @@
{% endblock %}
{% block settings %}
<h4>{% trans "Stock Options" %}</h4>
<table class='table table-striped table-condensed'>
<thead></thead>
{% include "InvenTree/settings/header.html" %}
<tbody>
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_ENABLE_EXPIRY" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_STALE_DAYS" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_SALE" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_BUILD" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" %}
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends "collapse_index.html" %}
{% load i18n %}
{% block collapse_title %}
<span class='fas fa-stopwatch icon-header'></span>
{% trans "Stale Stock" %}<span class='badge' id='stale-stock-count'><span class='fas fa-spin fa-spinner'></span></span>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' id='stale-stock-table'>
</table>
{% endblock %}

View File

@ -40,6 +40,7 @@
<link rel="stylesheet" href="{% static 'css/select2-bootstrap.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-toggle.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-table-filter-control.css' %}">
<link rel="stylesheet" href="{% static 'fullcalendar/main.css' %}">
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">
<link rel="stylesheet" href="{% get_color_theme_css user.get_username %}">
@ -103,6 +104,7 @@ InvenTree
<script type='text/javascript' src="{% static 'script/bootstrap/bootstrap-table-filter-control.js' %}"></script>
<!-- <script type='text/javascript' src="{% static 'script/bootstrap/filter-control-utils.js' %}"></script> -->
<script type="text/javascript" src="{% static 'fullcalendar/main.js' %}"></script>
<script type="text/javascript" src="{% static 'script/select2/select2.js' %}"></script>
<script type='text/javascript' src="{% static 'script/moment.js' %}"></script>
@ -121,6 +123,7 @@ InvenTree
<script type='text/javascript' src="{% url 'stock.js' %}"></script>
<script type='text/javascript' src="{% url 'build.js' %}"></script>
<script type='text/javascript' src="{% url 'order.js' %}"></script>
<script type='text/javascript' src="{% url 'calendar.js' %}"></script>
<script type='text/javascript' src="{% url 'table_filters.js' %}"></script>
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>

View File

@ -1,6 +1,6 @@
{% block collapse_preamble %}
{% endblock %}
<div class='panel-group'>
<div class='panel-group panel-index'>
<div class='panel panel-default'>
<div {% block collapse_panel_setup %}class='panel panel-heading'{% endblock %}>
<div class='panel-title'>

View File

@ -0,0 +1,25 @@
{% load i18n %}
/**
* Helper functions for calendar display
*/
function startDate(calendar) {
// Extract the first displayed date on the calendar
return calendar.currentData.dateProfile.activeRange.start.toISOString().split("T")[0];
}
function endDate(calendar) {
// Extract the last display date on the calendar
return calendar.currentData.dateProfile.activeRange.end.toISOString().split("T")[0];
}
function clearEvents(calendar) {
// Remove all events from the calendar
var events = calendar.getEvents();
events.forEach(function(event) {
event.remove();
})
}

View File

@ -1,4 +1,5 @@
{% load i18n %}
{% load inventree_extras %}
{% load status_codes %}
/* Stock API functions
@ -278,7 +279,7 @@ function loadStockTable(table, options) {
if (row.is_building && row.build) {
// StockItem is currently being built!
text = "{% trans "In production" %}";
text = '{% trans "In production" %}';
url = `/build/${row.build}/`;
} else if (row.belongs_to) {
// StockItem is installed inside a different StockItem
@ -286,17 +287,17 @@ function loadStockTable(table, options) {
url = `/stock/item/${row.belongs_to}/installed/`;
} else if (row.customer) {
// StockItem has been assigned to a customer
text = "{% trans "Shipped to customer" %}";
text = '{% trans "Shipped to customer" %}';
url = `/company/${row.customer}/assigned-stock/`;
} else if (row.sales_order) {
// StockItem has been assigned to a sales order
text = "{% trans "Assigned to Sales Order" %}";
text = '{% trans "Assigned to Sales Order" %}';
url = `/order/sales-order/${row.sales_order}/`;
} else if (row.location) {
text = row.location_detail.pathstring;
url = `/stock/location/${row.location}/`;
} else {
text = "<i>{% trans "No stock location set" %}</i>";
text = '<i>{% trans "No stock location set" %}</i>';
url = '';
}
@ -336,7 +337,13 @@ function loadStockTable(table, options) {
return html;
}
else if (field == 'part_detail.IPN') {
return row.part_detail.IPN;
var ipn = row.part_detail.IPN;
if (ipn) {
return ipn;
} else {
return '-';
}
}
else if (field == 'part_detail.description') {
return row.part_detail.description;
@ -526,6 +533,12 @@ function loadStockTable(table, options) {
html += makeIconBadge('fa-user', '{% trans "Stock item assigned to customer" %}');
}
if (row.expired) {
html += makeIconBadge('fa-calendar-times icon-red', '{% trans "Stock item has expired" %}');
} else if (row.stale) {
html += makeIconBadge('fa-stopwatch', '{% trans "Stock item will expire soon" %}');
}
if (row.allocated) {
html += makeIconBadge('fa-bookmark', '{% trans "Stock item has been allocated" %}');
}
@ -577,6 +590,14 @@ function loadStockTable(table, options) {
return locationDetail(row);
}
},
{% settings_value "STOCK_ENABLE_EXPIRY" as expiry %}
{% if expiry %}
{
field: 'expiry_date',
title: '{% trans "Expiry Date" %}',
sortable: true,
},
{% endif %}
{
field: 'notes',
title: '{% trans "Notes" %}',
@ -603,8 +624,8 @@ function loadStockTable(table, options) {
if (action == 'move') {
secondary.push({
field: 'destination',
label: 'New Location',
title: 'Create new location',
label: '{% trans "New Location" %}',
title: '{% trans "Create new location" %}',
url: "/stock/location/new/",
});
}
@ -822,14 +843,25 @@ function createNewStockItem(options) {
}
);
// Disable serial number field if the part is not trackable
// Request part information from the server
inventreeGet(
`/api/part/${value}/`, {},
{
success: function(response) {
// Disable serial number field if the part is not trackable
enableField('serial_numbers', response.trackable);
clearField('serial_numbers');
// Populate the expiry date
if (response.default_expiry <= 0) {
// No expiry date
clearField('expiry_date');
} else {
var expiry = moment().add(response.default_expiry, 'days');
setFieldValue('expiry_date', expiry.format("YYYY-MM-DD"));
}
}
}
);

View File

@ -106,6 +106,16 @@ function getAvailableTableFilters(tableKey) {
title: '{% trans "Depleted" %}',
description: '{% trans "Show stock items which are depleted" %}',
},
expired: {
type: 'bool',
title: '{% trans "Expired" %}',
description: '{% trans "Show stock items which have expired" %}',
},
stale: {
type: 'bool',
title: '{% trans "Stale" %}',
description: '{% trans "Show stock which is close to expiring" %}',
},
in_stock: {
type: 'bool',
title: '{% trans "In Stock" %}',