2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Merge branch 'inventree:master' into matmair/issue2694

This commit is contained in:
Matthias Mair
2022-04-05 02:03:40 +02:00
committed by GitHub
54 changed files with 20257 additions and 15514 deletions

View File

@ -251,3 +251,104 @@
rght: 0
expiry_date: "1990-10-10"
status: 70
# Multiple stock items for "Bob" (PK 100)
- model: stock.stockitem
pk: 1000
fields:
part: 100
location: 1
quantity: 10
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1001
fields:
part: 100
location: 1
quantity: 11
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1002
fields:
part: 100
location: 1
quantity: 12
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1003
fields:
part: 100
location: 1
quantity: 13
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1004
fields:
part: 100
location: 1
quantity: 14
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1005
fields:
part: 100
location: 1
quantity: 15
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1006
fields:
part: 100
location: 1
quantity: 16
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1007
fields:
part: 100
location: 7
quantity: 17
level: 0
tree_id: 0
lft: 0
rght: 0
- model: stock.stockitem
pk: 1008
fields:
part: 100
location: 7
quantity: 18
level: 0
tree_id: 0
lft: 0
rght: 0

View File

@ -49,15 +49,20 @@
</div>
{% endif %}
<!-- Document / label menu -->
{% if test_report_enabled or labels_enabled %}
<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>
<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>
{% endif %}
{% 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>
{% endif %}
</ul>
</div>
{% endif %}
<!-- Stock adjustment menu -->
{% if user_owns_item %}
{% 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>
<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>
{% if labels_enabled %}
<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>
</ul>
</div>
@ -181,6 +183,7 @@
<div id='sublocation-button-toolbar'>
<div class='btn-group' role='group'>
<!-- Printing actions menu -->
{% if labels_enabled %}
<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" %}'>
<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>
</ul>
</div>
{% endif %}
{% include "filter_list.html" with id="location" %}
</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() {
var selections = $('#sublocation-table').bootstrapTable('getSelections');
@ -234,6 +247,7 @@
printStockLocationLabels(locations);
});
{% endif %}
{% if location %}
$("#barcode-check-in").click(function() {
@ -298,14 +312,6 @@
adjustLocationStock('move');
});
$('#print-label').click(function() {
var locs = [{{ location.pk }}];
printStockLocationLabels(locs);
});
{% endif %}
$('#show-qr-code').click(function() {

View File

@ -104,7 +104,7 @@ class StockItemListTest(StockAPITestCase):
response = self.get_stock()
self.assertEqual(len(response), 20)
self.assertEqual(len(response), 29)
def test_filter_by_part(self):
"""
@ -113,7 +113,7 @@ class StockItemListTest(StockAPITestCase):
response = self.get_stock(part=25)
self.assertEqual(len(response), 8)
self.assertEqual(len(response), 17)
response = self.get_stock(part=10004)
@ -136,13 +136,13 @@ class StockItemListTest(StockAPITestCase):
self.assertEqual(len(response), 1)
response = self.get_stock(location=1, cascade=0)
self.assertEqual(len(response), 0)
self.assertEqual(len(response), 7)
response = self.get_stock(location=1, cascade=1)
self.assertEqual(len(response), 2)
self.assertEqual(len(response), 9)
response = self.get_stock(location=7)
self.assertEqual(len(response), 16)
self.assertEqual(len(response), 18)
def test_filter_by_depleted(self):
"""
@ -153,7 +153,7 @@ class StockItemListTest(StockAPITestCase):
self.assertEqual(len(response), 1)
response = self.get_stock(depleted=0)
self.assertEqual(len(response), 19)
self.assertEqual(len(response), 28)
def test_filter_by_in_stock(self):
"""
@ -161,7 +161,7 @@ class StockItemListTest(StockAPITestCase):
"""
response = self.get_stock(in_stock=1)
self.assertEqual(len(response), 17)
self.assertEqual(len(response), 26)
response = self.get_stock(in_stock=0)
self.assertEqual(len(response), 3)
@ -172,7 +172,7 @@ class StockItemListTest(StockAPITestCase):
"""
codes = {
StockStatus.OK: 18,
StockStatus.OK: 27,
StockStatus.DESTROYED: 1,
StockStatus.LOST: 1,
StockStatus.DAMAGED: 0,
@ -205,7 +205,7 @@ class StockItemListTest(StockAPITestCase):
self.assertIsNotNone(item['serial'])
response = self.get_stock(serialized=0)
self.assertEqual(len(response), 8)
self.assertEqual(len(response), 17)
for item in response:
self.assertIsNone(item['serial'])
@ -217,7 +217,7 @@ class StockItemListTest(StockAPITestCase):
# First, we can assume that the 'stock expiry' feature is disabled
response = self.get_stock(expired=1)
self.assertEqual(len(response), 20)
self.assertEqual(len(response), 29)
self.user.is_staff = True
self.user.save()
@ -232,7 +232,7 @@ class StockItemListTest(StockAPITestCase):
self.assertTrue(item['expired'])
response = self.get_stock(expired=0)
self.assertEqual(len(response), 19)
self.assertEqual(len(response), 28)
for item in response:
self.assertFalse(item['expired'])
@ -249,7 +249,7 @@ class StockItemListTest(StockAPITestCase):
self.assertEqual(len(response), 4)
response = self.get_stock(expired=0)
self.assertEqual(len(response), 16)
self.assertEqual(len(response), 25)
def test_paginate(self):
"""
@ -290,7 +290,8 @@ class StockItemListTest(StockAPITestCase):
dataset = self.export_data({})
self.assertEqual(len(dataset), 20)
# Check that *all* stock item objects have been exported
self.assertEqual(len(dataset), StockItem.objects.count())
# Expected headers
headers = [
@ -308,11 +309,11 @@ class StockItemListTest(StockAPITestCase):
# Now, add a filter to the results
dataset = self.export_data({'location': 1})
self.assertEqual(len(dataset), 2)
self.assertEqual(len(dataset), 9)
dataset = self.export_data({'part': 25})
self.assertEqual(len(dataset), 8)
self.assertEqual(len(dataset), 17)
class StockItemTest(StockAPITestCase):

View File

@ -167,8 +167,8 @@ class StockTest(TestCase):
self.assertFalse(self.drawer2.has_items())
# Drawer 3 should have three stock items
self.assertEqual(self.drawer3.stock_items.count(), 16)
self.assertEqual(self.drawer3.item_count, 16)
self.assertEqual(self.drawer3.stock_items.count(), 18)
self.assertEqual(self.drawer3.item_count, 18)
def test_stock_count(self):
part = Part.objects.get(pk=1)