Merge branch 'master' into search-megamenu

This commit is contained in:
Oliver Walters 2022-03-28 21:56:30 +11:00
commit 92bff3d1b7
10 changed files with 71 additions and 30 deletions

View File

@ -196,7 +196,7 @@ def isInvenTreeUpToDate():
and stores it to the database as INVENTREE_LATEST_VERSION and stores it to the database as INVENTREE_LATEST_VERSION
""" """
latest = common.models.InvenTreeSetting.get_setting('INVENTREE_LATEST_VERSION', None) latest = common.models.InvenTreeSetting.get_setting('INVENTREE_LATEST_VERSION', backup_value=None, create=False)
# No record for "latest" version - we must assume we are up to date! # No record for "latest" version - we must assume we are up to date!
if not latest: if not latest:

View File

@ -1247,6 +1247,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'validator': bool, 'validator': bool,
}, },
'LABEL_ENABLE': {
'name': _('Enable label printing'),
'description': _('Enable label printing from the web interface'),
'default': True,
'validator': bool,
},
"LABEL_INLINE": { "LABEL_INLINE": {
'name': _('Inline label display'), 'name': _('Inline label display'),
'description': _('Display PDF labels in the browser, instead of downloading as a file'), 'description': _('Display PDF labels in the browser, instead of downloading as a file'),

View File

@ -37,13 +37,17 @@
</button> </button>
{% endif %} {% endif %}
{% if barcodes %} {% if barcodes or labels_enabled %}
<!-- Barcode actions menu --> <!-- Barcode actions menu -->
<div class='btn-group'> <div class='btn-group'>
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button> <button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'> <ul class='dropdown-menu'>
{% if barcodes %}
<li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li> <li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
{% endif %}
{% if labels_enabled %}
<li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li> <li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
{% endif %}
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
@ -424,9 +428,11 @@
); );
}); });
{% if labels_enabled %}
$('#print-label').click(function() { $('#print-label').click(function() {
printPartLabels([{{ part.pk }}]); printPartLabels([{{ part.pk }}]);
}); });
{% endif %}
function adjustPartStock(action) { function adjustPartStock(action) {
inventreeGet( inventreeGet(

View File

@ -49,15 +49,20 @@
</div> </div>
{% endif %} {% endif %}
<!-- Document / label menu --> <!-- Document / label menu -->
{% if test_report_enabled or labels_enabled %}
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
<button id='document-options' title='{% trans "Printing actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-print'></span> <span class='caret'></span></button> <button id='document-options' title='{% trans "Printing actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-print'></span> <span class='caret'></span></button>
<ul class='dropdown-menu' role='menu'> <ul class='dropdown-menu' role='menu'>
{% if labels_enabled %}
<li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li> <li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
{% endif %}
{% if test_report_enabled %} {% if test_report_enabled %}
<li><a class='dropdown-item' href='#' id='stock-test-report'><span class='fas fa-file-pdf'></span> {% trans "Test Report" %}</a></li> <li><a class='dropdown-item' href='#' id='stock-test-report'><span class='fas fa-file-pdf'></span> {% trans "Test Report" %}</a></li>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
{% endif %}
<!-- Stock adjustment menu --> <!-- Stock adjustment menu -->
{% if user_owns_item %} {% if user_owns_item %}
{% if roles.stock.change and not item.is_building %} {% if roles.stock.change and not item.is_building %}

View File

@ -34,7 +34,9 @@
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button> <button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'> <ul class='dropdown-menu'>
<li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li> <li><a class='dropdown-item' href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
{% if labels_enabled %}
<li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li> <li><a class='dropdown-item' href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li> <li><a class='dropdown-item' href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
</ul> </ul>
</div> </div>
@ -181,6 +183,7 @@
<div id='sublocation-button-toolbar'> <div id='sublocation-button-toolbar'>
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
<!-- Printing actions menu --> <!-- Printing actions menu -->
{% if labels_enabled %}
<div class='btn-group' role='group'> <div class='btn-group' role='group'>
<button id='location-print-options' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle="dropdown" title='{% trans "Printing Actions" %}'> <button id='location-print-options' class='btn btn-outline-secondary dropdown-toggle' type='button' data-bs-toggle="dropdown" title='{% trans "Printing Actions" %}'>
<span class='fas fa-print'></span> <span class='caret'></span> <span class='fas fa-print'></span> <span class='caret'></span>
@ -189,6 +192,7 @@
<li><a class='dropdown-item' href='#' id='multi-location-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li> <li><a class='dropdown-item' href='#' id='multi-location-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li>
</ul> </ul>
</div> </div>
{% endif %}
{% include "filter_list.html" with id="location" %} {% include "filter_list.html" with id="location" %}
</div> </div>
</div> </div>
@ -222,6 +226,15 @@
] ]
); );
{% if labels_enabled %}
$('#print-label').click(function() {
var locs = [{{ location.pk }}];
printStockLocationLabels(locs);
});
$('#multi-location-print-label').click(function() { $('#multi-location-print-label').click(function() {
var selections = $('#sublocation-table').bootstrapTable('getSelections'); var selections = $('#sublocation-table').bootstrapTable('getSelections');
@ -234,6 +247,7 @@
printStockLocationLabels(locations); printStockLocationLabels(locations);
}); });
{% endif %}
{% if location %} {% if location %}
$("#barcode-check-in").click(function() { $("#barcode-check-in").click(function() {
@ -298,14 +312,6 @@
adjustLocationStock('move'); adjustLocationStock('move');
}); });
$('#print-label').click(function() {
var locs = [{{ location.pk }}];
printStockLocationLabels(locs);
});
{% endif %} {% endif %}
$('#show-qr-code').click(function() { $('#show-qr-code').click(function() {

View File

@ -14,6 +14,7 @@
<div class='row'> <div class='row'>
<table class='table table-striped table-condensed'> <table class='table table-striped table-condensed'>
<tbody> <tbody>
{% include "InvenTree/settings/setting.html" with key="LABEL_ENABLE" icon='fa-toggle-on' user_setting=True %}
{% include "InvenTree/settings/setting.html" with key="LABEL_INLINE" icon='fa-tag' user_setting=True %} {% include "InvenTree/settings/setting.html" with key="LABEL_INLINE" icon='fa-tag' user_setting=True %}
</tbody> </tbody>
</table> </table>

View File

@ -6,6 +6,7 @@
{% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %} {% settings_value 'REPORT_ENABLE_TEST_REPORT' as test_report_enabled %}
{% settings_value "REPORT_ENABLE" as report_enabled %} {% settings_value "REPORT_ENABLE" as report_enabled %}
{% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %} {% settings_value "SERVER_RESTART_REQUIRED" as server_restart_required %}
{% settings_value "LABEL_ENABLE" with user=user as labels_enabled %}
{% inventree_demo_mode as demo_mode %} {% inventree_demo_mode as demo_mode %}
<!DOCTYPE html> <!DOCTYPE html>

View File

@ -4,6 +4,7 @@
editSetting, editSetting,
user_settings, user_settings,
global_settings, global_settings,
plugins_enabled,
*/ */
{% user_settings request.user as USER_SETTINGS %} {% user_settings request.user as USER_SETTINGS %}
@ -20,6 +21,13 @@ const global_settings = {
{% endfor %} {% endfor %}
}; };
{% plugins_enabled as p_en %}
{% if p_en %}
const plugins_enabled = true;
{% else %}
const plugins_enabled = false;
{% endif %}
/* /*
* Edit a setting value * Edit a setting value
*/ */

View File

@ -1025,9 +1025,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
} }
// Store the required quantity in the row data // Store the required quantity in the row data
row.required = quantity; // Prevent weird rounding issues
row.required = parseFloat(quantity.toFixed(15));
return quantity; return row.required;
} }
function sumAllocations(row) { function sumAllocations(row) {
@ -1043,9 +1044,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
quantity += item.quantity; quantity += item.quantity;
}); });
row.allocated = quantity; row.allocated = parseFloat(quantity.toFixed(15));
return quantity; return row.allocated;
} }
function setupCallbacks() { function setupCallbacks() {
@ -1642,6 +1643,9 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) {
remaining = 0; remaining = 0;
} }
// Ensure the quantity sent to the form field is correctly formatted
remaining = parseFloat(remaining.toFixed(15));
// We only care about entries which are not yet fully allocated // We only care about entries which are not yet fully allocated
if (remaining > 0) { if (remaining > 0) {
table_entries += renderBomItemRow(bom_item, remaining); table_entries += renderBomItemRow(bom_item, remaining);

View File

@ -10,6 +10,7 @@
modalSetTitle, modalSetTitle,
modalSubmit, modalSubmit,
openModal, openModal,
plugins_enabled,
showAlertDialog, showAlertDialog,
*/ */
@ -232,26 +233,28 @@ function selectLabel(labels, items, options={}) {
var plugins = []; var plugins = [];
// Request a list of available label printing plugins from the server // Request a list of available label printing plugins from the server
inventreeGet( if (plugins_enabled) {
`/api/plugin/`, inventreeGet(
{}, `/api/plugin/`,
{ {},
async: false, {
success: function(response) { async: false,
response.forEach(function(plugin) { success: function(response) {
// Look for active plugins which implement the 'labels' mixin class response.forEach(function(plugin) {
if (plugin.active && plugin.mixins && plugin.mixins.labels) { // Look for active plugins which implement the 'labels' mixin class
// This plugin supports label printing if (plugin.active && plugin.mixins && plugin.mixins.labels) {
plugins.push(plugin); // This plugin supports label printing
} plugins.push(plugin);
}); }
});
}
} }
} );
); }
var plugin_selection = ''; var plugin_selection = '';
if (plugins.length > 0) { if (plugins_enabled && plugins.length > 0) {
plugin_selection =` plugin_selection =`
<div class='form-group'> <div class='form-group'>
<label class='control-label requiredField' for='id_plugin'> <label class='control-label requiredField' for='id_plugin'>