mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
4b728520ac
@ -196,23 +196,23 @@ INSTALLED_APPS = [
|
|||||||
'users.apps.UsersConfig',
|
'users.apps.UsersConfig',
|
||||||
|
|
||||||
# Third part add-ons
|
# Third part add-ons
|
||||||
'django_filters', # Extended filter functionality
|
'django_filters', # Extended filter functionality
|
||||||
'dbbackup', # Database backup / restore
|
'dbbackup', # Database backup / restore
|
||||||
'rest_framework', # DRF (Django Rest Framework)
|
'rest_framework', # DRF (Django Rest Framework)
|
||||||
'rest_framework.authtoken', # Token authentication for API
|
'rest_framework.authtoken', # Token authentication for API
|
||||||
'corsheaders', # Cross-origin Resource Sharing for DRF
|
'corsheaders', # Cross-origin Resource Sharing for DRF
|
||||||
'crispy_forms', # Improved form rendering
|
'crispy_forms', # Improved form rendering
|
||||||
'import_export', # Import / export tables to file
|
'import_export', # Import / export tables to file
|
||||||
'django_cleanup', # Automatically delete orphaned MEDIA files
|
'django_cleanup.apps.CleanupConfig', # Automatically delete orphaned MEDIA files
|
||||||
'qr_code', # Generate QR codes
|
'qr_code', # Generate QR codes
|
||||||
'mptt', # Modified Preorder Tree Traversal
|
'mptt', # Modified Preorder Tree Traversal
|
||||||
'markdownx', # Markdown editing
|
'markdownx', # Markdown editing
|
||||||
'markdownify', # Markdown template rendering
|
'markdownify', # Markdown template rendering
|
||||||
'django_tex', # LaTeX output
|
'django_tex', # LaTeX output
|
||||||
'django_admin_shell', # Python shell for the admin interface
|
'django_admin_shell', # Python shell for the admin interface
|
||||||
'djmoney', # django-money integration
|
'djmoney', # django-money integration
|
||||||
'djmoney.contrib.exchange', # django-money exchange rates
|
'djmoney.contrib.exchange', # django-money exchange rates
|
||||||
'error_report', # Error reporting in the admin interface
|
'error_report', # Error reporting in the admin interface
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = CONFIG.get('middleware', [
|
MIDDLEWARE = CONFIG.get('middleware', [
|
||||||
|
@ -8,11 +8,33 @@ function deleteButton(url, text='Delete') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderLink(text, url) {
|
function renderLink(text, url, options={}) {
|
||||||
if (text === '' || url === '') {
|
if (url == null || url === '') {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var max_length = options.max_length || -1;
|
||||||
|
|
||||||
|
var remove_http = options.remove_http || false;
|
||||||
|
|
||||||
|
if (remove_http) {
|
||||||
|
if (text.startsWith('http://')) {
|
||||||
|
text = text.slice(7);
|
||||||
|
} else if (text.startsWith('https://')) {
|
||||||
|
text = text.slice(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shorten the displayed length if required
|
||||||
|
if ((max_length > 0) && (text.length > max_length)) {
|
||||||
|
var slice_length = (max_length - 3) / 2;
|
||||||
|
|
||||||
|
var text_start = text.slice(0, slice_length);
|
||||||
|
var text_end = text.slice(-slice_length);
|
||||||
|
|
||||||
|
text = `${text_start}...${text_end}`;
|
||||||
|
}
|
||||||
|
|
||||||
return '<a href="' + url + '">' + text + '</a>';
|
return '<a href="' + url + '">' + text + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class BarcodeScan(APIView):
|
|||||||
|
|
||||||
if loc is not None:
|
if loc is not None:
|
||||||
response['stocklocation'] = plugin.renderStockLocation(loc)
|
response['stocklocation'] = plugin.renderStockLocation(loc)
|
||||||
response['url'] = reverse('location-detail', kwargs={'pk': loc.id})
|
response['url'] = reverse('stock-location-detail', kwargs={'pk': loc.id})
|
||||||
match_found = True
|
match_found = True
|
||||||
|
|
||||||
# Try to associate with a part
|
# Try to associate with a part
|
||||||
|
@ -225,22 +225,19 @@ class Build(MPTTModel):
|
|||||||
blank=True, help_text=_('Extra build notes')
|
blank=True, help_text=_('Extra build notes')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
def is_overdue(self):
|
def is_overdue(self):
|
||||||
"""
|
"""
|
||||||
Returns true if this build is "overdue":
|
Returns true if this build is "overdue":
|
||||||
|
|
||||||
- Not completed
|
Makes use of the OVERDUE_FILTER to avoid code duplication
|
||||||
- Target date is "in the past"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Cannot be deemed overdue if target_date is not set
|
query = Build.objects.filter(pk=self.pk)
|
||||||
if self.target_date is None:
|
query = query.filter(Build.OVERDUE_FILTER)
|
||||||
return False
|
|
||||||
|
|
||||||
today = datetime.now().date()
|
|
||||||
|
|
||||||
return self.active and self.target_date < today
|
|
||||||
|
|
||||||
|
return query.exists()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active(self):
|
def active(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,6 +10,7 @@ from rest_framework.test import APITestCase
|
|||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from .models import Build
|
from .models import Build
|
||||||
from stock.models import StockItem
|
from stock.models import StockItem
|
||||||
@ -70,6 +71,24 @@ class BuildTestSimple(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(b2.status, BuildStatus.COMPLETE)
|
self.assertEqual(b2.status, BuildStatus.COMPLETE)
|
||||||
|
|
||||||
|
def test_overdue(self):
|
||||||
|
"""
|
||||||
|
Test overdue status functionality
|
||||||
|
"""
|
||||||
|
|
||||||
|
today = datetime.now().date()
|
||||||
|
|
||||||
|
build = Build.objects.get(pk=1)
|
||||||
|
self.assertFalse(build.is_overdue)
|
||||||
|
|
||||||
|
build.target_date = today - timedelta(days=1)
|
||||||
|
build.save()
|
||||||
|
self.assertTrue(build.is_overdue)
|
||||||
|
|
||||||
|
build.target_date = today + timedelta(days=80)
|
||||||
|
build.save()
|
||||||
|
self.assertFalse(build.is_overdue)
|
||||||
|
|
||||||
def test_is_active(self):
|
def test_is_active(self):
|
||||||
b1 = Build.objects.get(pk=1)
|
b1 = Build.objects.get(pk=1)
|
||||||
b2 = Build.objects.get(pk=2)
|
b2 = Build.objects.get(pk=2)
|
||||||
|
@ -71,6 +71,13 @@ class InvenTreeSetting(models.Model):
|
|||||||
'choices': djmoney.settings.CURRENCY_CHOICES,
|
'choices': djmoney.settings.CURRENCY_CHOICES,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'BARCODE_ENABLE': {
|
||||||
|
'name': _('Barcode Support'),
|
||||||
|
'description': _('Enable barcode scanner support'),
|
||||||
|
'default': True,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
|
|
||||||
'PART_IPN_REGEX': {
|
'PART_IPN_REGEX': {
|
||||||
'name': _('IPN Regex'),
|
'name': _('IPN Regex'),
|
||||||
'description': _('Regular expression pattern for matching Part IPN')
|
'description': _('Regular expression pattern for matching Part IPN')
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -272,6 +272,7 @@ class PurchaseOrder(Order):
|
|||||||
self.complete_date = datetime.now().date()
|
self.complete_date = datetime.now().date()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
@property
|
||||||
def is_overdue(self):
|
def is_overdue(self):
|
||||||
"""
|
"""
|
||||||
Returns True if this PurchaseOrder is "overdue"
|
Returns True if this PurchaseOrder is "overdue"
|
||||||
@ -455,7 +456,7 @@ class SalesOrder(Order):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
query = SalesOrder.objects.filter(pk=self.pk)
|
query = SalesOrder.objects.filter(pk=self.pk)
|
||||||
query = query.filer(SalesOrder.OVERDUE_FILTER)
|
query = query.filter(SalesOrder.OVERDUE_FILTER)
|
||||||
|
|
||||||
return query.exists()
|
return query.exists()
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ from django.test import TestCase
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db.utils import IntegrityError
|
from django.db.utils import IntegrityError
|
||||||
|
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from company.models import Company
|
from company.models import Company
|
||||||
from stock.models import StockItem
|
from stock.models import StockItem
|
||||||
from order.models import SalesOrder, SalesOrderLineItem, SalesOrderAllocation
|
from order.models import SalesOrder, SalesOrderLineItem, SalesOrderAllocation
|
||||||
@ -40,6 +42,26 @@ class SalesOrderTest(TestCase):
|
|||||||
# Create a line item
|
# Create a line item
|
||||||
self.line = SalesOrderLineItem.objects.create(quantity=50, order=self.order, part=self.part)
|
self.line = SalesOrderLineItem.objects.create(quantity=50, order=self.order, part=self.part)
|
||||||
|
|
||||||
|
def test_overdue(self):
|
||||||
|
"""
|
||||||
|
Tests for overdue functionality
|
||||||
|
"""
|
||||||
|
|
||||||
|
today = datetime.now().date()
|
||||||
|
|
||||||
|
# By default, order is *not* overdue as the target date is not set
|
||||||
|
self.assertFalse(self.order.is_overdue)
|
||||||
|
|
||||||
|
# Set target date in the past
|
||||||
|
self.order.target_date = today - timedelta(days=5)
|
||||||
|
self.order.save()
|
||||||
|
self.assertTrue(self.order.is_overdue)
|
||||||
|
|
||||||
|
# Set target date in the future
|
||||||
|
self.order.target_date = today + timedelta(days=5)
|
||||||
|
self.order.save()
|
||||||
|
self.assertFalse(self.order.is_overdue)
|
||||||
|
|
||||||
def test_empty_order(self):
|
def test_empty_order(self):
|
||||||
self.assertEqual(self.line.quantity, 50)
|
self.assertEqual(self.line.quantity, 50)
|
||||||
self.assertEqual(self.line.allocated_quantity(), 0)
|
self.assertEqual(self.line.allocated_quantity(), 0)
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
import django.core.exceptions as django_exceptions
|
import django.core.exceptions as django_exceptions
|
||||||
|
|
||||||
@ -37,6 +41,24 @@ class OrderTest(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(str(line), "100 x ACME0001 from ACME (for PO0001 - ACME)")
|
self.assertEqual(str(line), "100 x ACME0001 from ACME (for PO0001 - ACME)")
|
||||||
|
|
||||||
|
def test_overdue(self):
|
||||||
|
"""
|
||||||
|
Test overdue status functionality
|
||||||
|
"""
|
||||||
|
|
||||||
|
today = datetime.now().date()
|
||||||
|
|
||||||
|
order = PurchaseOrder.objects.get(pk=1)
|
||||||
|
self.assertFalse(order.is_overdue)
|
||||||
|
|
||||||
|
order.target_date = today - timedelta(days=5)
|
||||||
|
order.save()
|
||||||
|
self.assertTrue(order.is_overdue)
|
||||||
|
|
||||||
|
order.target_date = today + timedelta(days=1)
|
||||||
|
order.save()
|
||||||
|
self.assertFalse(order.is_overdue)
|
||||||
|
|
||||||
def test_increment(self):
|
def test_increment(self):
|
||||||
|
|
||||||
next_ref = PurchaseOrder.getNextOrderNumber()
|
next_ref = PurchaseOrder.getNextOrderNumber()
|
||||||
|
@ -6,6 +6,7 @@ Part database model definitions
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
@ -51,6 +52,9 @@ import common.models
|
|||||||
import part.settings as part_settings
|
import part.settings as part_settings
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PartCategory(InvenTreeTree):
|
class PartCategory(InvenTreeTree):
|
||||||
""" PartCategory provides hierarchical organization of Part objects.
|
""" PartCategory provides hierarchical organization of Part objects.
|
||||||
|
|
||||||
@ -335,11 +339,14 @@ class Part(MPTTModel):
|
|||||||
if self.pk:
|
if self.pk:
|
||||||
previous = Part.objects.get(pk=self.pk)
|
previous = Part.objects.get(pk=self.pk)
|
||||||
|
|
||||||
if previous.image and not self.image == previous.image:
|
# Image has been changed
|
||||||
|
if previous.image is not None and not self.image == previous.image:
|
||||||
|
|
||||||
# Are there any (other) parts which reference the image?
|
# Are there any (other) parts which reference the image?
|
||||||
n_refs = Part.objects.filter(image=previous.image).exclude(pk=self.pk).count()
|
n_refs = Part.objects.filter(image=previous.image).exclude(pk=self.pk).count()
|
||||||
|
|
||||||
if n_refs == 0:
|
if n_refs == 0:
|
||||||
|
logger.info(f"Deleting unused image file '{previous.image}'")
|
||||||
previous.image.delete(save=False)
|
previous.image.delete(save=False)
|
||||||
|
|
||||||
self.clean()
|
self.clean()
|
||||||
@ -710,7 +717,7 @@ class Part(MPTTModel):
|
|||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
variations={'thumbnail': (128, 128)},
|
variations={'thumbnail': (128, 128)},
|
||||||
delete_orphans=True,
|
delete_orphans=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
default_location = TreeForeignKey(
|
default_location = TreeForeignKey(
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
<span id='part-star-icon' class='fas fa-star {% if starred %}icon-yellow{% endif %}'/>
|
<span id='part-star-icon' class='fas fa-star {% if starred %}icon-yellow{% endif %}'/>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
{% if barcodes %}
|
||||||
<!-- 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-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
|
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
|
||||||
@ -52,6 +54,7 @@
|
|||||||
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
|
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if part.active %}
|
{% if part.active %}
|
||||||
<button type='button' class='btn btn-default' id='price-button' title='{% trans "Show pricing information" %}'>
|
<button type='button' class='btn btn-default' id='price-button' title='{% trans "Show pricing information" %}'>
|
||||||
<span id='part-price-icon' class='fas fa-dollar-sign'/>
|
<span id='part-price-icon' class='fas fa-dollar-sign'/>
|
||||||
|
@ -121,12 +121,17 @@ class StockAdjust(APIView):
|
|||||||
- StockAdd: add stock items
|
- StockAdd: add stock items
|
||||||
- StockRemove: remove stock items
|
- StockRemove: remove stock items
|
||||||
- StockTransfer: transfer stock items
|
- StockTransfer: transfer stock items
|
||||||
|
|
||||||
|
# TODO - This needs serious refactoring!!!
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
permissions.IsAuthenticated,
|
permissions.IsAuthenticated,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
allow_missing_quantity = False
|
||||||
|
|
||||||
def get_items(self, request):
|
def get_items(self, request):
|
||||||
"""
|
"""
|
||||||
Return a list of items posted to the endpoint.
|
Return a list of items posted to the endpoint.
|
||||||
@ -157,10 +162,13 @@ class StockAdjust(APIView):
|
|||||||
except (ValueError, StockItem.DoesNotExist):
|
except (ValueError, StockItem.DoesNotExist):
|
||||||
raise ValidationError({'pk': 'Each entry must contain a valid pk field'})
|
raise ValidationError({'pk': 'Each entry must contain a valid pk field'})
|
||||||
|
|
||||||
|
if self.allow_missing_quantity and 'quantity' not in entry:
|
||||||
|
entry['quantity'] = item.quantity
|
||||||
|
|
||||||
try:
|
try:
|
||||||
quantity = Decimal(str(entry.get('quantity', None)))
|
quantity = Decimal(str(entry.get('quantity', None)))
|
||||||
except (ValueError, TypeError, InvalidOperation):
|
except (ValueError, TypeError, InvalidOperation):
|
||||||
raise ValidationError({'quantity': 'Each entry must contain a valid quantity field'})
|
raise ValidationError({'quantity': "Each entry must contain a valid quantity value"})
|
||||||
|
|
||||||
if quantity < 0:
|
if quantity < 0:
|
||||||
raise ValidationError({'quantity': 'Quantity field must not be less than zero'})
|
raise ValidationError({'quantity': 'Quantity field must not be less than zero'})
|
||||||
@ -234,6 +242,8 @@ class StockTransfer(StockAdjust):
|
|||||||
API endpoint for performing stock movements
|
API endpoint for performing stock movements
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
allow_missing_quantity = True
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
|
||||||
self.get_items(request)
|
self.get_items(request)
|
||||||
|
@ -120,6 +120,8 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='btn-group action-buttons' role='group'>
|
<div class='btn-group action-buttons' role='group'>
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
{% if barcodes %}
|
||||||
<!-- 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-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
|
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
|
||||||
@ -127,24 +129,26 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
|
|||||||
<li><a href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
|
<li><a href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
|
||||||
{% if roles.stock.change %}
|
{% if roles.stock.change %}
|
||||||
{% if item.uid %}
|
{% if item.uid %}
|
||||||
<li><a href='#' id='unlink-barcode'><span class='fas fa-unlink'></span> {% trans "Unlink Barcode" %}</a></li>
|
<li><a href='#' id='barcode-unlink'><span class='fas fa-unlink'></span> {% trans "Unlink Barcode" %}</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href='#' id='link-barcode'><span class='fas fa-link'></span> {% trans "Link Barcode" %}</a></li>
|
<li><a href='#' id='barcode-link'><span class='fas fa-link'></span> {% trans "Link Barcode" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
<li><a href='#' id='barcode-scan-into-location'><span class='fas fa-sitemap'></span> {% trans "Scan to Location" %}</a></li>
|
||||||
</ul>
|
{% endif %}
|
||||||
</div>
|
</ul>
|
||||||
<!-- Document / label menu -->
|
</div>
|
||||||
{% if item.has_labels or item.has_test_reports %}
|
{% endif %}
|
||||||
<div class='btn-group'>
|
<!-- Document / label menu -->
|
||||||
<button id='document-options' title='{% trans "Printing actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-print'></span> <span class='caret'></span></button>
|
{% if item.has_labels or item.has_test_reports %}
|
||||||
<ul class='dropdown-menu' role='menu'>
|
<div class='btn-group'>
|
||||||
{% if item.has_labels %}
|
<button id='document-options' title='{% trans "Printing actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-print'></span> <span class='caret'></span></button>
|
||||||
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
|
<ul class='dropdown-menu' role='menu'>
|
||||||
{% endif %}
|
{% if item.has_labels %}
|
||||||
{% if item.has_test_reports %}
|
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
|
||||||
<li><a href='#' id='stock-test-report'><span class='fas fa-file-pdf'></span> {% trans "Test Report" %}</a></li>
|
{% endif %}
|
||||||
{% endif %}
|
{% if item.has_test_reports %}
|
||||||
|
<li><a href='#' id='stock-test-report'><span class='fas fa-file-pdf'></span> {% trans "Test Report" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -447,14 +451,18 @@ $("#show-qr-code").click(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#link-barcode").click(function() {
|
$("#barcode-link").click(function() {
|
||||||
linkBarcodeDialog({{ item.id }});
|
linkBarcodeDialog({{ item.id }});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#unlink-barcode").click(function() {
|
$("#barcode-unlink").click(function() {
|
||||||
unlinkBarcode({{ item.id }});
|
unlinkBarcode({{ item.id }});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#barcode-scan-into-location").click(function() {
|
||||||
|
scanItemsIntoLocation([{{ item.id }}]);
|
||||||
|
});
|
||||||
|
|
||||||
{% if item.in_stock %}
|
{% if item.in_stock %}
|
||||||
|
|
||||||
$("#stock-assign-to-customer").click(function() {
|
$("#stock-assign-to-customer").click(function() {
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
{% if barcodes %}
|
||||||
<!-- Barcode actions menu -->
|
<!-- Barcode actions menu -->
|
||||||
{% if location %}
|
{% if location %}
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
@ -47,29 +49,30 @@
|
|||||||
<li><a href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
|
<li><a href='#' id='barcode-check-in'><span class='fas fa-arrow-right'></span> {% trans "Check-in Items" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- Check permissions and owner -->
|
{% endif %}
|
||||||
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %}
|
<!-- Check permissions and owner -->
|
||||||
{% if roles.stock.change %}
|
{% if owner_control.value == "False" or owner_control.value == "True" and user in owners or user.is_superuser %}
|
||||||
<div class='btn-group'>
|
{% if roles.stock.change %}
|
||||||
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>
|
<div class='btn-group'>
|
||||||
<ul class='dropdown-menu' role='menu'>
|
<button id='stock-actions' title='{% trans "Stock actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-boxes'></span> <span class='caret'></span></button>
|
||||||
<li><a href='#' id='location-count'><span class='fas fa-clipboard-list'></span>
|
<ul class='dropdown-menu' role='menu'>
|
||||||
{% trans "Count stock" %}</a></li>
|
<li><a href='#' id='location-count'><span class='fas fa-clipboard-list'></span>
|
||||||
</ul>
|
{% trans "Count stock" %}</a></li>
|
||||||
</div>
|
</ul>
|
||||||
{% endif %}
|
</div>
|
||||||
{% if roles.stock_location.change %}
|
|
||||||
<div class='btn-group'>
|
|
||||||
<button id='location-actions' title='{% trans "Location actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle="dropdown"><span class='fas fa-sitemap'></span> <span class='caret'></span></button>
|
|
||||||
<ul class='dropdown-menu' role='menu'>
|
|
||||||
<li><a href='#' id='location-edit'><span class='fas fa-edit icon-green'></span> {% trans "Edit location" %}</a></li>
|
|
||||||
{% if roles.stock.delete %}
|
|
||||||
<li><a href='#' id='location-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete location" %}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if roles.stock_location.change %}
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button id='location-actions' title='{% trans "Location actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle="dropdown"><span class='fas fa-sitemap'></span> <span class='caret'></span></button>
|
||||||
|
<ul class='dropdown-menu' role='menu'>
|
||||||
|
<li><a href='#' id='location-edit'><span class='fas fa-edit icon-green'></span> {% trans "Edit location" %}</a></li>
|
||||||
|
{% if roles.stock.delete %}
|
||||||
|
<li><a href='#' id='location-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete location" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,4 +21,12 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h4>{% trans "Barcode Settings" %}</h4>
|
||||||
|
<table class='table table-striped table-condensed'>
|
||||||
|
{% include "InvenTree/settings/header.html" %}
|
||||||
|
<tbody>
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="BARCODE_ENABLE" icon="fa-qrcode" %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -2,6 +2,8 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -145,9 +147,11 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
showCachedAlerts();
|
showCachedAlerts();
|
||||||
|
|
||||||
|
{% if barcodes %}
|
||||||
$('#barcode-scan').click(function() {
|
$('#barcode-scan').click(function() {
|
||||||
barcodeScanDialog();
|
barcodeScanDialog();
|
||||||
});
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
function makeBarcodeInput(placeholderText='') {
|
function makeBarcodeInput(placeholderText='', hintText='') {
|
||||||
/*
|
/*
|
||||||
* Generate HTML for a barcode input
|
* Generate HTML for a barcode input
|
||||||
*/
|
*/
|
||||||
|
|
||||||
placeholderText = placeholderText || '{% trans "Scan barcode data here using wedge scanner" %}';
|
placeholderText = placeholderText || '{% trans "Scan barcode data here using wedge scanner" %}';
|
||||||
|
|
||||||
|
hintText = hintText || '{% trans "Enter barcode data" %}';
|
||||||
|
|
||||||
var html = `
|
var html = `
|
||||||
<div class='form-group'>
|
<div class='form-group'>
|
||||||
<label class='control-label' for='barcode'>{% trans "Barcode" %}</label>
|
<label class='control-label' for='barcode'>{% trans "Barcode" %}</label>
|
||||||
@ -17,7 +19,7 @@ function makeBarcodeInput(placeholderText='') {
|
|||||||
</span>
|
</span>
|
||||||
<input id='barcode' class='textinput textInput form-control' type='text' name='barcode' placeholder='${placeholderText}'>
|
<input id='barcode' class='textinput textInput form-control' type='text' name='barcode' placeholder='${placeholderText}'>
|
||||||
</div>
|
</div>
|
||||||
<div id='hint_barcode_data' class='help-block'>{% trans "Enter barcode data" %}</div>
|
<div id='hint_barcode_data' class='help-block'>${hintText}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -25,6 +27,81 @@ function makeBarcodeInput(placeholderText='') {
|
|||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeNotesField(options={}) {
|
||||||
|
|
||||||
|
var tooltip = options.tooltip || '{% trans "Enter optional notes for stock transfer" %}';
|
||||||
|
var placeholder = options.placeholder || '{% trans "Enter notes" %}';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class='form-group'>
|
||||||
|
<label class='control-label' for='notes'>{% trans "Notes" %}</label>
|
||||||
|
<div class='controls'>
|
||||||
|
<div class='input-group'>
|
||||||
|
<span class='input-group-addon'>
|
||||||
|
<span class='fas fa-sticky-note'></span>
|
||||||
|
</span>
|
||||||
|
<input id='notes' class='textinput textInput form-control' type='text' name='notes' placeholder='${placeholder}'>
|
||||||
|
</div>
|
||||||
|
<div id='hint_notes' class='help_block'>${tooltip}</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* POST data to the server, and handle standard responses.
|
||||||
|
*/
|
||||||
|
function postBarcodeData(barcode_data, options={}) {
|
||||||
|
|
||||||
|
var modal = options.modal || '#modal-form';
|
||||||
|
|
||||||
|
var url = options.url || '/api/barcode/';
|
||||||
|
|
||||||
|
var data = options.data || {};
|
||||||
|
|
||||||
|
data.barcode = barcode_data;
|
||||||
|
|
||||||
|
inventreePut(
|
||||||
|
url,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
error: function() {
|
||||||
|
enableBarcodeInput(modal, true);
|
||||||
|
showBarcodeMessage(modal, '{% trans "Server error" %}');
|
||||||
|
},
|
||||||
|
success: function(response, status) {
|
||||||
|
modalEnable(modal, false);
|
||||||
|
enableBarcodeInput(modal, true);
|
||||||
|
|
||||||
|
if (status == 'success') {
|
||||||
|
|
||||||
|
if ('success' in response) {
|
||||||
|
if (options.onScan) {
|
||||||
|
options.onScan(response);
|
||||||
|
}
|
||||||
|
} else if ('error' in response) {
|
||||||
|
showBarcodeMessage(
|
||||||
|
modal,
|
||||||
|
response.error,
|
||||||
|
'warning'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showBarcodeMessage(
|
||||||
|
modal,
|
||||||
|
'{% trans "Unknown response from server" %}',
|
||||||
|
'warning'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Invalid response returned from server
|
||||||
|
showInvalidResponseError(modal, response, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function showBarcodeMessage(modal, message, style='danger') {
|
function showBarcodeMessage(modal, message, style='danger') {
|
||||||
|
|
||||||
@ -43,12 +120,6 @@ function showInvalidResponseError(modal, response, status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function clearBarcodeError(modal, message) {
|
|
||||||
|
|
||||||
$(modal + ' #barcode-error-message').html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function enableBarcodeInput(modal, enabled=true) {
|
function enableBarcodeInput(modal, enabled=true) {
|
||||||
|
|
||||||
var barcode = $(modal + ' #barcode');
|
var barcode = $(modal + ' #barcode');
|
||||||
@ -87,9 +158,7 @@ function barcodeDialog(title, options={}) {
|
|||||||
|
|
||||||
if (barcode && barcode.length > 0) {
|
if (barcode && barcode.length > 0) {
|
||||||
|
|
||||||
if (options.onScan) {
|
postBarcodeData(barcode, options);
|
||||||
options.onScan(barcode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,40 +258,20 @@ function barcodeScanDialog() {
|
|||||||
barcodeDialog(
|
barcodeDialog(
|
||||||
"Scan Barcode",
|
"Scan Barcode",
|
||||||
{
|
{
|
||||||
onScan: function(barcode) {
|
onScan: function(response) {
|
||||||
enableBarcodeInput(modal, false);
|
if ('url' in response) {
|
||||||
inventreePut(
|
$(modal).modal('hide');
|
||||||
'/api/barcode/',
|
|
||||||
{
|
// Redirect to the URL!
|
||||||
barcode: barcode,
|
window.location.href = response.url;
|
||||||
},
|
} else {
|
||||||
{
|
showBarcodeMessage(
|
||||||
method: 'POST',
|
modal,
|
||||||
success: function(response, status) {
|
'{% trans "No URL in response" %}',
|
||||||
|
'warning'
|
||||||
enableBarcodeInput(modal, true);
|
);
|
||||||
|
}
|
||||||
if (status == 'success') {
|
}
|
||||||
|
|
||||||
if ('success' in response) {
|
|
||||||
if ('url' in response) {
|
|
||||||
// Redirect to the URL!
|
|
||||||
$(modal).modal('hide');
|
|
||||||
window.location.href = response.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if ('error' in response) {
|
|
||||||
showBarcodeMessage(modal, response.error, 'warning');
|
|
||||||
} else {
|
|
||||||
showBarcodeMessage(modal, "{% trans 'Unknown response from server' %}", 'warning');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showInvalidResponseError(modal, response, status);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -238,37 +287,14 @@ function linkBarcodeDialog(stockitem, options={}) {
|
|||||||
barcodeDialog(
|
barcodeDialog(
|
||||||
"{% trans 'Link Barcode to Stock Item' %}",
|
"{% trans 'Link Barcode to Stock Item' %}",
|
||||||
{
|
{
|
||||||
onScan: function(barcode) {
|
url: '/api/barcode/link/',
|
||||||
enableBarcodeInput(modal, false);
|
data: {
|
||||||
inventreePut(
|
stockitem: stockitem,
|
||||||
'/api/barcode/link/',
|
},
|
||||||
{
|
onScan: function(response) {
|
||||||
barcode: barcode,
|
|
||||||
stockitem: stockitem,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
success: function(response, status) {
|
|
||||||
|
|
||||||
enableBarcodeInput(modal, true);
|
$(modal).modal('hide');
|
||||||
|
location.reload();
|
||||||
if (status == 'success') {
|
|
||||||
|
|
||||||
if ('success' in response) {
|
|
||||||
$(modal).modal('hide');
|
|
||||||
location.reload();
|
|
||||||
} else if ('error' in response) {
|
|
||||||
showBarcodeMessage(modal, response.error, 'warning');
|
|
||||||
} else {
|
|
||||||
showBarcodeMessage(modal, "{% trans 'Unknown response from server' %}", warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
showInvalidResponseError(modal, response, status);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -386,22 +412,10 @@ function barcodeCheckIn(location_id, options={}) {
|
|||||||
var table = `<div class='container' id='items-table-div' style='width: 80%; float: left;'></div>`;
|
var table = `<div class='container' id='items-table-div' style='width: 80%; float: left;'></div>`;
|
||||||
|
|
||||||
// Extra form fields
|
// Extra form fields
|
||||||
var extra = `
|
var extra = makeNotesField();
|
||||||
<div class='form-group'>
|
|
||||||
<label class='control-label' for='notes'>{% trans "Notes" %}</label>
|
|
||||||
<div class='controls'>
|
|
||||||
<div class='input-group'>
|
|
||||||
<span class='input-group-addon'>
|
|
||||||
<span class='fas fa-sticky-note'></span>
|
|
||||||
</span>
|
|
||||||
<input id='notes' class='textinput textInput form-control' type='text' name='notes' placeholder='{% trans "Enter notes" %}'>
|
|
||||||
</div>
|
|
||||||
<div id='hint_notes' class='help_block'>{% trans "Enter optional notes for stock transfer" %}</div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
barcodeDialog(
|
barcodeDialog(
|
||||||
"{% trans "Check Stock Items into Location" %}",
|
'{% trans "Check Stock Items into Location" %}',
|
||||||
{
|
{
|
||||||
headerContent: table,
|
headerContent: table,
|
||||||
preShow: function() {
|
preShow: function() {
|
||||||
@ -414,7 +428,6 @@ function barcodeCheckIn(location_id, options={}) {
|
|||||||
extraFields: extra,
|
extraFields: extra,
|
||||||
onSubmit: function() {
|
onSubmit: function() {
|
||||||
|
|
||||||
|
|
||||||
// Called when the 'check-in' button is pressed
|
// Called when the 'check-in' button is pressed
|
||||||
|
|
||||||
var data = {location: location_id};
|
var data = {location: location_id};
|
||||||
@ -434,7 +447,7 @@ function barcodeCheckIn(location_id, options={}) {
|
|||||||
data.items = entries;
|
data.items = entries;
|
||||||
|
|
||||||
inventreePut(
|
inventreePut(
|
||||||
'{% url 'api-stock-transfer' %}',
|
"{% url 'api-stock-transfer' %}",
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -446,69 +459,154 @@ function barcodeCheckIn(location_id, options={}) {
|
|||||||
showAlertOrCache('alert-success', response.success, true);
|
showAlertOrCache('alert-success', response.success, true);
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
showAlertOrCache('alert-success', 'Error transferring stock', false);
|
showAlertOrCache('alert-success', '{% trans "Error transferring stock" %}', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onScan: function(barcode) {
|
onScan: function(response) {
|
||||||
enableBarcodeInput(modal, false);
|
if ('stockitem' in response) {
|
||||||
inventreePut(
|
stockitem = response.stockitem;
|
||||||
'/api/barcode/',
|
|
||||||
{
|
|
||||||
barcode: barcode,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
error: function() {
|
|
||||||
enableBarcodeInput(modal, true);
|
|
||||||
showBarcodeMessage(modal, '{% trans "Server error" %}');
|
|
||||||
},
|
|
||||||
success: function(response, status) {
|
|
||||||
|
|
||||||
enableBarcodeInput(modal, true);
|
var duplicate = false;
|
||||||
|
|
||||||
if (status == 'success') {
|
items.forEach(function(item) {
|
||||||
if ('stockitem' in response) {
|
if (item.pk == stockitem.pk) {
|
||||||
stockitem = response.stockitem;
|
duplicate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var duplicate = false;
|
if (duplicate) {
|
||||||
|
showBarcodeMessage(modal, '{% trans "Stock Item already scanned" %}', "warning");
|
||||||
|
} else {
|
||||||
|
|
||||||
items.forEach(function(item) {
|
if (stockitem.location == location_id) {
|
||||||
if (item.pk == stockitem.pk) {
|
showBarcodeMessage(modal, '{% trans "Stock Item already in this location" %}');
|
||||||
duplicate = true;
|
return;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (duplicate) {
|
// Add this stock item to the list
|
||||||
showBarcodeMessage(modal, "{% trans "Stock Item already scanned" %}", "warning");
|
items.push(stockitem);
|
||||||
} else {
|
|
||||||
|
|
||||||
if (stockitem.location == location_id) {
|
showBarcodeMessage(modal, '{% trans "Added stock item" %}', "success");
|
||||||
showBarcodeMessage(modal, "{% trans "Stock Item already in this location" %}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this stock item to the list
|
reloadTable();
|
||||||
items.push(stockitem);
|
}
|
||||||
|
|
||||||
showBarcodeMessage(modal, "{% trans "Added stock item" %}", "success");
|
} else {
|
||||||
|
// Barcode does not match a stock item
|
||||||
reloadTable();
|
showBarcodeMessage(modal, '{% trans "Barcode does not match Stock Item" %}', "warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
// Barcode does not match a stock item
|
|
||||||
showBarcodeMessage(modal, "{% trans "Barcode does not match Stock Item" %}", "warning");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
showInvalidResponseError(modal, response, status);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display dialog to check a single stock item into a stock location
|
||||||
|
*/
|
||||||
|
function scanItemsIntoLocation(item_id_list, options={}) {
|
||||||
|
|
||||||
|
var modal = options.modal || '#modal-form';
|
||||||
|
|
||||||
|
var stock_location = null;
|
||||||
|
|
||||||
|
// Extra form fields
|
||||||
|
var extra = makeNotesField();
|
||||||
|
|
||||||
|
// Header contentfor
|
||||||
|
var header = `
|
||||||
|
<div id='header-div'>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
function updateLocationInfo(location) {
|
||||||
|
var div = $(modal + ' #header-div');
|
||||||
|
|
||||||
|
if (stock_location && stock_location.pk) {
|
||||||
|
div.html(`
|
||||||
|
<div class='alert alert-block alert-info'>
|
||||||
|
<b>{% trans "Location" %}</b></br>
|
||||||
|
${stock_location.name}<br>
|
||||||
|
<i>${stock_location.description}</i>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
div.html('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
barcodeDialog(
|
||||||
|
'{% trans "Check Into Location" %}',
|
||||||
|
{
|
||||||
|
headerContent: header,
|
||||||
|
extraFields: extra,
|
||||||
|
preShow: function() {
|
||||||
|
modalSetSubmitText(modal, '{% trans "Check In" %}');
|
||||||
|
modalEnable(modal, false);
|
||||||
|
},
|
||||||
|
onShow: function() {
|
||||||
|
},
|
||||||
|
onSubmit: function() {
|
||||||
|
// Called when the 'check-in' button is pressed
|
||||||
|
if (!stock_location) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = [];
|
||||||
|
|
||||||
|
item_id_list.forEach(function(pk) {
|
||||||
|
items.push({
|
||||||
|
pk: pk,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
location: stock_location.pk,
|
||||||
|
notes: $(modal + ' #notes').val(),
|
||||||
|
items: items,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send API request
|
||||||
|
inventreePut(
|
||||||
|
'{% url "api-stock-transfer" %}',
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
success: function(response, status) {
|
||||||
|
// First hide the modal
|
||||||
|
$(modal).modal('hide');
|
||||||
|
|
||||||
|
if (status == 'success' && 'success' in response) {
|
||||||
|
showAlertOrCache('alert-success', response.success, true);
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
showAlertOrCache('alert-danger', '{% trans "Error transferring stock" %}', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onScan: function(response) {
|
||||||
|
updateLocationInfo(null);
|
||||||
|
if ('stocklocation' in response) {
|
||||||
|
// Barcode corresponds to a StockLocation
|
||||||
|
stock_location = response.stocklocation;
|
||||||
|
|
||||||
|
updateLocationInfo(stock_location);
|
||||||
|
modalEnable(modal, true);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Barcode does *NOT* correspond to a StockLocation
|
||||||
|
showBarcodeMessage(
|
||||||
|
modal,
|
||||||
|
'{% trans "Barcode does not match a valid location" %}',
|
||||||
|
"warning",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
@ -446,6 +446,20 @@ function loadPartTable(table, url, options={}) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
columns.push({
|
||||||
|
field: 'link',
|
||||||
|
title: '{% trans "Link" %}',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(
|
||||||
|
value, value,
|
||||||
|
{
|
||||||
|
max_length: 32,
|
||||||
|
remove_http: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(table).inventreeTable({
|
$(table).inventreeTable({
|
||||||
url: url,
|
url: url,
|
||||||
sortName: 'name',
|
sortName: 'name',
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
* Requires api.js to be loaded first
|
* Requires api.js to be loaded first
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
|
||||||
function stockStatusCodes() {
|
function stockStatusCodes() {
|
||||||
return [
|
return [
|
||||||
@ -635,6 +636,9 @@ function loadStockTable(table, options) {
|
|||||||
table,
|
table,
|
||||||
[
|
[
|
||||||
'#stock-print-options',
|
'#stock-print-options',
|
||||||
|
{% if barcodes %}
|
||||||
|
'#stock-barcode-options',
|
||||||
|
{% endif %}
|
||||||
'#stock-options',
|
'#stock-options',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@ -700,6 +704,20 @@ function loadStockTable(table, options) {
|
|||||||
printTestReports(items);
|
printTestReports(items);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
{% if barcodes %}
|
||||||
|
$('#multi-item-barcode-scan-into-location').click(function() {
|
||||||
|
var selections = $('#stock-table').bootstrapTable('getSelections');
|
||||||
|
|
||||||
|
var items = [];
|
||||||
|
|
||||||
|
selections.forEach(function(item) {
|
||||||
|
items.push(item.pk);
|
||||||
|
})
|
||||||
|
|
||||||
|
scanItemsIntoLocation(items);
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
$('#multi-item-stocktake').click(function() {
|
$('#multi-item-stocktake').click(function() {
|
||||||
stockAdjustment('count');
|
stockAdjustment('count');
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load inventree_extras %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
|
||||||
<nav class="navbar navbar-xs navbar-default navbar-fixed-top ">
|
<nav class="navbar navbar-xs navbar-default navbar-fixed-top ">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header clearfix content-heading">
|
<div class="navbar-header clearfix content-heading">
|
||||||
@ -46,11 +50,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
{% include "search_form.html" %}
|
{% include "search_form.html" %}
|
||||||
|
{% if barcodes %}
|
||||||
<li id='navbar-barcode-li'>
|
<li id='navbar-barcode-li'>
|
||||||
<button id='barcode-scan' class='btn btn-default' title='{% trans "Scan Barcode" %}'>
|
<button id='barcode-scan' class='btn btn-default' title='{% trans "Scan Barcode" %}'>
|
||||||
<span class='fas fa-qrcode'></span>
|
<span class='fas fa-qrcode'></span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li class='dropdown'>
|
<li class='dropdown'>
|
||||||
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
|
<a class='dropdown-toggle' data-toggle='dropdown' href="#">
|
||||||
{% if not system_healthy %}
|
{% if not system_healthy %}
|
||||||
@ -61,14 +67,13 @@
|
|||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{% if user.is_staff %}
|
{% if user.is_staff %}
|
||||||
<li><a href="/admin/"><span class="fas fa-user"></span> {% trans "Admin" %}</a></li>
|
<li><a href="/admin/"><span class="fas fa-user"></span> {% trans "Admin" %}</a></li>
|
||||||
<hr>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="{% url 'settings' %}"><span class="fas fa-cog"></span> {% trans "Settings" %}</a></li>
|
|
||||||
<li><a href="{% url 'logout' %}"><span class="fas fa-sign-out-alt"></span> {% trans "Logout" %}</a></li>
|
<li><a href="{% url 'logout' %}"><span class="fas fa-sign-out-alt"></span> {% trans "Logout" %}</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{% url 'login' %}"><span class="fas fa-sign-in-alt"></span> {% trans "Login" %}</a></li>
|
<li><a href="{% url 'login' %}"><span class="fas fa-sign-in-alt"></span> {% trans "Login" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<hr>
|
<hr>
|
||||||
|
<li><a href="{% url 'settings' %}"><span class="fas fa-cog"></span> {% trans "Settings" %}</a></li>
|
||||||
<li id='launch-stats'><a href='#'>
|
<li id='launch-stats'><a href='#'>
|
||||||
{% if system_healthy %}
|
{% if system_healthy %}
|
||||||
<span class='fas fa-server'>
|
<span class='fas fa-server'>
|
||||||
@ -83,4 +88,4 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
|
{% settings_value 'BARCODE_ENABLE' as barcodes %}
|
||||||
|
|
||||||
{% 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 %}
|
||||||
@ -19,6 +21,17 @@
|
|||||||
<span class='fas fa-plus-circle'></span>
|
<span class='fas fa-plus-circle'></span>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if barcodes %}
|
||||||
|
<!-- Barcode actions menu -->
|
||||||
|
<div class='btn-group'>
|
||||||
|
<button id='stock-barcode-options' class='btn btn-primary dropdown-toggle' type='button' data-toggle='dropdown' title='{% trans "Barcode Actions" %}'>
|
||||||
|
<span class='fas fa-qrcode'></span> <span class='caret'></span>
|
||||||
|
</button>
|
||||||
|
<ul class='dropdown-menu'>
|
||||||
|
<li><a href='#' id='multi-item-barcode-scan-into-location' title='{% trans "Scan to Location" %}'><span class='fas fa-sitemap'></span> {% trans "Scan to Location" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
<button id='stock-print-options' class='btn btn-primary dropdown-toggle' type='button' data-toggle="dropdown" title='{% trans "Printing Actions" %}'>
|
<button id='stock-print-options' class='btn btn-primary dropdown-toggle' type='button' data-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>
|
||||||
|
@ -15,7 +15,7 @@ pygments==2.2.0 # Syntax highlighting
|
|||||||
tablib==0.13.0 # Import / export data files
|
tablib==0.13.0 # Import / export data files
|
||||||
django-crispy-forms==1.8.1 # Form helpers
|
django-crispy-forms==1.8.1 # Form helpers
|
||||||
django-import-export==2.0.0 # Data import / export for admin interface
|
django-import-export==2.0.0 # Data import / export for admin interface
|
||||||
django-cleanup==4.0.0 # Manage deletion of old / unused uploaded files
|
django-cleanup==5.1.0 # Manage deletion of old / unused uploaded files
|
||||||
django-qr-code==1.2.0 # Generate QR codes
|
django-qr-code==1.2.0 # Generate QR codes
|
||||||
flake8==3.8.3 # PEP checking
|
flake8==3.8.3 # PEP checking
|
||||||
pep8-naming==0.11.1 # PEP naming convention extension
|
pep8-naming==0.11.1 # PEP naming convention extension
|
||||||
|
Loading…
Reference in New Issue
Block a user