mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge branch 'inventree:master' into plugin-2037
This commit is contained in:
commit
9d1c146a40
30
.github/ISSUE_TEMPLATE/app_issue.md
vendored
30
.github/ISSUE_TEMPLATE/app_issue.md
vendored
@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
name: App issue
|
|
||||||
about: Report a bug or issue with the InvenTree app
|
|
||||||
title: "[APP] Enter bug description"
|
|
||||||
labels: bug, app
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of the bug or issue
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
|
|
||||||
1. Go to ...
|
|
||||||
2. Select ...
|
|
||||||
3. ...
|
|
||||||
|
|
||||||
**Expected Behavior**
|
|
||||||
A clear and concise description of what you expected to happen
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem
|
|
||||||
|
|
||||||
**Version Information**
|
|
||||||
|
|
||||||
- App platform: *Select iOS or Android*
|
|
||||||
- App version: *Enter app version*
|
|
||||||
- Server version: *Enter server version*
|
|
@ -8,7 +8,7 @@ import re
|
|||||||
|
|
||||||
import common.models
|
import common.models
|
||||||
|
|
||||||
INVENTREE_SW_VERSION = "0.5.0 dev"
|
INVENTREE_SW_VERSION = "0.6.0 dev"
|
||||||
|
|
||||||
INVENTREE_API_VERSION = 12
|
INVENTREE_API_VERSION = 12
|
||||||
|
|
||||||
@ -88,9 +88,6 @@ def isInvenTreeDevelopmentVersion():
|
|||||||
"""
|
"""
|
||||||
Return True if current InvenTree version is a "development" version
|
Return True if current InvenTree version is a "development" version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print("is dev?", inventreeVersion())
|
|
||||||
|
|
||||||
return inventreeVersion().endswith('dev')
|
return inventreeVersion().endswith('dev')
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@ from __future__ import unicode_literals
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from django.core.exceptions import ValidationError as DjangoValidationError
|
||||||
|
|
||||||
from django_filters import rest_framework as rest_filters
|
from django_filters import rest_framework as rest_filters
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from rest_framework import filters, status
|
from rest_framework import filters, status
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import serializers
|
||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@ -243,11 +245,12 @@ class POReceive(generics.CreateAPIView):
|
|||||||
|
|
||||||
pk = self.kwargs.get('pk', None)
|
pk = self.kwargs.get('pk', None)
|
||||||
|
|
||||||
if pk is None:
|
try:
|
||||||
return None
|
order = PurchaseOrder.objects.get(pk=pk)
|
||||||
else:
|
except (PurchaseOrder.DoesNotExist, ValueError):
|
||||||
order = PurchaseOrder.objects.get(pk=self.kwargs['pk'])
|
raise ValidationError(_("Matching purchase order does not exist"))
|
||||||
return order
|
|
||||||
|
return order
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
|
||||||
@ -259,9 +262,14 @@ class POReceive(generics.CreateAPIView):
|
|||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
||||||
# Receive the line items
|
# Receive the line items
|
||||||
self.receive_items(serializer)
|
try:
|
||||||
|
self.receive_items(serializer)
|
||||||
|
except DjangoValidationError as exc:
|
||||||
|
# Re-throw a django error as a DRF error
|
||||||
|
raise ValidationError(detail=serializers.as_serializer_error(exc))
|
||||||
|
|
||||||
headers = self.get_success_headers(serializer.data)
|
headers = self.get_success_headers(serializer.data)
|
||||||
|
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -418,16 +418,24 @@ class PurchaseOrder(Order):
|
|||||||
barcode = ''
|
barcode = ''
|
||||||
|
|
||||||
if not self.status == PurchaseOrderStatus.PLACED:
|
if not self.status == PurchaseOrderStatus.PLACED:
|
||||||
raise ValidationError({"status": _("Lines can only be received against an order marked as 'Placed'")})
|
raise ValidationError(
|
||||||
|
"Lines can only be received against an order marked as 'PLACED'"
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not (quantity % 1 == 0):
|
if not (quantity % 1 == 0):
|
||||||
raise ValidationError({"quantity": _("Quantity must be an integer")})
|
raise ValidationError({
|
||||||
|
"quantity": _("Quantity must be an integer")
|
||||||
|
})
|
||||||
if quantity < 0:
|
if quantity < 0:
|
||||||
raise ValidationError({"quantity": _("Quantity must be a positive number")})
|
raise ValidationError({
|
||||||
|
"quantity": _("Quantity must be a positive number")
|
||||||
|
})
|
||||||
quantity = int(quantity)
|
quantity = int(quantity)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
raise ValidationError({"quantity": _("Invalid quantity provided")})
|
raise ValidationError({
|
||||||
|
"quantity": _("Invalid quantity provided")
|
||||||
|
})
|
||||||
|
|
||||||
# Create a new stock item
|
# Create a new stock item
|
||||||
if line.part and quantity > 0:
|
if line.part and quantity > 0:
|
||||||
|
@ -401,25 +401,45 @@ class PurchaseOrderReceiveTest(OrderTest):
|
|||||||
self.assertEqual(line_1.received, 0)
|
self.assertEqual(line_1.received, 0)
|
||||||
self.assertEqual(line_2.received, 50)
|
self.assertEqual(line_2.received, 50)
|
||||||
|
|
||||||
|
valid_data = {
|
||||||
|
'items': [
|
||||||
|
{
|
||||||
|
'line_item': 1,
|
||||||
|
'quantity': 50,
|
||||||
|
'barcode': 'MY-UNIQUE-BARCODE-123',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'line_item': 2,
|
||||||
|
'quantity': 200,
|
||||||
|
'location': 2, # Explicit location
|
||||||
|
'barcode': 'MY-UNIQUE-BARCODE-456',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'location': 1, # Default location
|
||||||
|
}
|
||||||
|
|
||||||
|
# Before posting "valid" data, we will mark the purchase order as "pending"
|
||||||
|
# In this case we do expect an error!
|
||||||
|
order = PurchaseOrder.objects.get(pk=1)
|
||||||
|
order.status = PurchaseOrderStatus.PENDING
|
||||||
|
order.save()
|
||||||
|
|
||||||
|
response = self.post(
|
||||||
|
self.url,
|
||||||
|
valid_data,
|
||||||
|
expected_code=400
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertIn('can only be received against', str(response.data))
|
||||||
|
|
||||||
|
# Now, set the PO back to "PLACED" so the items can be received
|
||||||
|
order.status = PurchaseOrderStatus.PLACED
|
||||||
|
order.save()
|
||||||
|
|
||||||
# Receive two separate line items against this order
|
# Receive two separate line items against this order
|
||||||
self.post(
|
self.post(
|
||||||
self.url,
|
self.url,
|
||||||
{
|
valid_data,
|
||||||
'items': [
|
|
||||||
{
|
|
||||||
'line_item': 1,
|
|
||||||
'quantity': 50,
|
|
||||||
'barcode': 'MY-UNIQUE-BARCODE-123',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'line_item': 2,
|
|
||||||
'quantity': 200,
|
|
||||||
'location': 2, # Explicit location
|
|
||||||
'barcode': 'MY-UNIQUE-BARCODE-456',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'location': 1, # Default location
|
|
||||||
},
|
|
||||||
expected_code=201,
|
expected_code=201,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@
|
|||||||
{% if roles.part.change %}
|
{% if roles.part.change %}
|
||||||
<li><a href='#' id='part-edit'><span class='fas fa-edit icon-blue'></span> {% trans "Edit part" %}</a></li>
|
<li><a href='#' id='part-edit'><span class='fas fa-edit icon-blue'></span> {% trans "Edit part" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not part.active and roles.part.delete %}
|
{% if roles.part.delete %}
|
||||||
<li><a href='#' id='part-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete part" %}</a></li>
|
<li><a href='#' id='part-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete part" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -503,12 +503,13 @@
|
|||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not part.active and roles.part.delete %}
|
{% if roles.part.delete %}
|
||||||
$("#part-delete").click(function() {
|
$("#part-delete").click(function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'part-delete' part.id %}",
|
"{% url 'part-delete' part.id %}",
|
||||||
{
|
{
|
||||||
redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %}
|
redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %},
|
||||||
|
no_post: {% if part.active %}true{% else %}false{% endif %},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
{% block pre_form_content %}
|
{% block pre_form_content %}
|
||||||
|
|
||||||
|
{% if part.active %}
|
||||||
|
|
||||||
|
<div class='alert alert-block alert-danger'>
|
||||||
|
{% blocktrans with full_name=part.full_name %}Part '<strong>{{full_name}}</strong>' cannot be deleted as it is still marked as <strong>active</strong>.
|
||||||
|
<br>Disable the "Active" part attribute and re-try.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
<div class='alert alert-block alert-danger'>
|
<div class='alert alert-block alert-danger'>
|
||||||
{% blocktrans with full_name=part.full_name %}Are you sure you want to delete part '<strong>{{full_name}}</strong>'?{% endblocktrans %}
|
{% blocktrans with full_name=part.full_name %}Are you sure you want to delete part '<strong>{{full_name}}</strong>'?{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
@ -55,4 +65,12 @@
|
|||||||
<p>{% blocktrans with count=part.serials.all|length full_name=part.full_name %}There are {{count}} unique parts tracked for '{{full_name}}'. Deleting this part will permanently remove this tracking information.{% endblocktrans %}</p>
|
<p>{% blocktrans with count=part.serials.all|length full_name=part.full_name %}There are {{count}} unique parts tracked for '{{full_name}}'. Deleting this part will permanently remove this tracking information.{% endblocktrans %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block form %}
|
||||||
|
{% if not part.active %}
|
||||||
|
{{ block.super }}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -109,6 +109,17 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
return super().update(request, *args, **kwargs)
|
return super().update(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def perform_destroy(self, instance):
|
||||||
|
"""
|
||||||
|
Instead of "deleting" the StockItem
|
||||||
|
(which may take a long time)
|
||||||
|
we instead schedule it for deletion at a later date.
|
||||||
|
|
||||||
|
The background worker will delete these in the future
|
||||||
|
"""
|
||||||
|
|
||||||
|
instance.mark_for_deletion()
|
||||||
|
|
||||||
|
|
||||||
class StockAdjust(APIView):
|
class StockAdjust(APIView):
|
||||||
"""
|
"""
|
||||||
|
@ -1650,9 +1650,6 @@ def before_delete_stock_item(sender, instance, using, **kwargs):
|
|||||||
child.parent = instance.parent
|
child.parent = instance.parent
|
||||||
child.save()
|
child.save()
|
||||||
|
|
||||||
# Rebuild the MPTT tree
|
|
||||||
StockItem.objects.rebuild()
|
|
||||||
|
|
||||||
|
|
||||||
class StockItemAttachment(InvenTreeAttachment):
|
class StockItemAttachment(InvenTreeAttachment):
|
||||||
"""
|
"""
|
||||||
|
@ -18,6 +18,7 @@ from InvenTree.api_tester import InvenTreeAPITestCase
|
|||||||
from common.models import InvenTreeSetting
|
from common.models import InvenTreeSetting
|
||||||
|
|
||||||
from .models import StockItem, StockLocation
|
from .models import StockItem, StockLocation
|
||||||
|
from .tasks import delete_old_stock_items
|
||||||
|
|
||||||
|
|
||||||
class StockAPITestCase(InvenTreeAPITestCase):
|
class StockAPITestCase(InvenTreeAPITestCase):
|
||||||
@ -37,6 +38,7 @@ class StockAPITestCase(InvenTreeAPITestCase):
|
|||||||
'stock.add',
|
'stock.add',
|
||||||
'stock_location.change',
|
'stock_location.change',
|
||||||
'stock_location.add',
|
'stock_location.add',
|
||||||
|
'stock.delete',
|
||||||
]
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -591,6 +593,60 @@ class StocktakeTest(StockAPITestCase):
|
|||||||
self.assertContains(response, 'Valid location must be specified', status_code=status.HTTP_400_BAD_REQUEST)
|
self.assertContains(response, 'Valid location must be specified', status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
class StockItemDeletionTest(StockAPITestCase):
|
||||||
|
"""
|
||||||
|
Tests for stock item deletion via the API
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_delete(self):
|
||||||
|
|
||||||
|
# Check there are no stock items scheduled for deletion
|
||||||
|
self.assertEqual(
|
||||||
|
StockItem.objects.filter(scheduled_for_deletion=True).count(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create and then delete a bunch of stock items
|
||||||
|
for idx in range(10):
|
||||||
|
|
||||||
|
# Create new StockItem via the API
|
||||||
|
response = self.post(
|
||||||
|
reverse('api-stock-list'),
|
||||||
|
{
|
||||||
|
'part': 1,
|
||||||
|
'location': 1,
|
||||||
|
'quantity': idx,
|
||||||
|
},
|
||||||
|
expected_code=201
|
||||||
|
)
|
||||||
|
|
||||||
|
pk = response.data['pk']
|
||||||
|
|
||||||
|
item = StockItem.objects.get(pk=pk)
|
||||||
|
|
||||||
|
self.assertFalse(item.scheduled_for_deletion)
|
||||||
|
|
||||||
|
# Request deletion via the API
|
||||||
|
self.delete(
|
||||||
|
reverse('api-stock-detail', kwargs={'pk': pk}),
|
||||||
|
expected_code=204
|
||||||
|
)
|
||||||
|
|
||||||
|
# There should be 100x StockItem objects marked for deletion
|
||||||
|
self.assertEqual(
|
||||||
|
StockItem.objects.filter(scheduled_for_deletion=True).count(),
|
||||||
|
10
|
||||||
|
)
|
||||||
|
|
||||||
|
# Perform the actual delete (will take some time)
|
||||||
|
delete_old_stock_items()
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
StockItem.objects.filter(scheduled_for_deletion=True).count(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class StockTestResultTest(StockAPITestCase):
|
class StockTestResultTest(StockAPITestCase):
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
"{% url 'api-part-list' %}",
|
"{% url 'api-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
},
|
},
|
||||||
checkbox: false,
|
checkbox: false,
|
||||||
disableFilters: true,
|
disableFilters: true,
|
||||||
@ -126,24 +126,10 @@
|
|||||||
|
|
||||||
addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap');
|
addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap');
|
||||||
|
|
||||||
$("#table-category").inventreeTable({
|
loadPartCategoryTable($("#table-category"), {
|
||||||
url: "{% url 'api-part-category-list' %}",
|
params: {
|
||||||
queryParams: {
|
original_search: "{{ query }}",
|
||||||
search: "{{ query }}",
|
}
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '{% trans "Name" %}',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return renderLink(value, '/part/category/' + row.pk + '/');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addItem('manufacturer-part', '{% trans "Manufacturer Parts" %}', 'fa-toolbox');
|
addItem('manufacturer-part', '{% trans "Manufacturer Parts" %}', 'fa-toolbox');
|
||||||
@ -153,7 +139,7 @@
|
|||||||
"{% url 'api-manufacturer-part-list' %}",
|
"{% url 'api-manufacturer-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
supplier_detail: true,
|
supplier_detail: true,
|
||||||
manufacturer_detail: true
|
manufacturer_detail: true
|
||||||
@ -168,7 +154,7 @@
|
|||||||
"{% url 'api-supplier-part-list' %}",
|
"{% url 'api-supplier-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
supplier_detail: true,
|
supplier_detail: true,
|
||||||
manufacturer_detail: true
|
manufacturer_detail: true
|
||||||
@ -186,7 +172,7 @@
|
|||||||
|
|
||||||
loadBuildTable('#table-build-order', {
|
loadBuildTable('#table-build-order', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -197,105 +183,23 @@
|
|||||||
|
|
||||||
addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes');
|
addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes');
|
||||||
|
|
||||||
$('#table-stock').inventreeTable({
|
loadStockTable($('#table-stock'), {
|
||||||
|
filterKey: 'stocksearch',
|
||||||
url: "{% url 'api-stock-list' %}",
|
url: "{% url 'api-stock-list' %}",
|
||||||
queryParams: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
location_detail: true,
|
location_detail: true
|
||||||
},
|
}
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'part',
|
|
||||||
title: "{% trans "Part" %}",
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row) {
|
|
||||||
var url = `/stock/item/${row.pk}/`;
|
|
||||||
var thumb = row.part_detail.thumbnail;
|
|
||||||
var name = row.part_detail.full_name;
|
|
||||||
|
|
||||||
html = imageHoverIcon(thumb) + renderLink(name, url);
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'part_description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return row.part_detail.description;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'quantity',
|
|
||||||
title: '{% trans "Stock" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
|
|
||||||
var val = parseFloat(value);
|
|
||||||
|
|
||||||
// If there is a single unit with a serial number, use the serial number
|
|
||||||
if (row.serial && row.quantity == 1) {
|
|
||||||
val = '# ' + row.serial;
|
|
||||||
} else {
|
|
||||||
val = +val.toFixed(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
var html = renderLink(val, `/stock/item/${row.pk}/`);
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'status',
|
|
||||||
title: '{% trans "Status" %}',
|
|
||||||
sortable: 'true',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return stockStatusDisplay(value);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'location_detail.pathstring',
|
|
||||||
title: '{% trans "Location" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
if (value) {
|
|
||||||
return renderLink(value, `/stock/location/${row.location}/`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (row.customer) {
|
|
||||||
var text = "{% trans "Shipped to customer" %}";
|
|
||||||
return renderLink(text, `/company/${row.customer}/assigned-stock/`);
|
|
||||||
} else {
|
|
||||||
return '<em>{% trans "No stock location set" %}</em>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt');
|
addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt');
|
||||||
|
|
||||||
$("#table-location").inventreeTable({
|
loadStockLocationTable($("#table-location"), {
|
||||||
url: "{% url 'api-location-list' %}",
|
filterKey: 'locationsearch',
|
||||||
queryParams: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
},
|
},
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '{% trans "Name" %}',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return renderLink(row.pathstring, '/stock/location/' + row.pk + '/');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -307,7 +211,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_manufacturer: "true",
|
is_manufacturer: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -317,7 +221,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_supplier: "true",
|
is_supplier: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -326,7 +230,7 @@
|
|||||||
|
|
||||||
loadPurchaseOrderTable('#table-purchase-order', {
|
loadPurchaseOrderTable('#table-purchase-order', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -337,7 +241,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_customer: "true",
|
is_customer: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -346,7 +250,7 @@
|
|||||||
|
|
||||||
loadSalesOrderTable('#table-sales-orders', {
|
loadSalesOrderTable('#table-sales-orders', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ function inventreeDocReady() {
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
var transformed = $.map(data.results, function(el) {
|
var transformed = $.map(data.results, function(el) {
|
||||||
return {
|
return {
|
||||||
label: el.name,
|
label: el.full_name,
|
||||||
id: el.pk,
|
id: el.pk,
|
||||||
thumbnail: el.thumbnail
|
thumbnail: el.thumbnail
|
||||||
};
|
};
|
||||||
|
@ -271,7 +271,7 @@ function loadBomTable(table, options) {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
|
|
||||||
var url = `/part/${row.sub_part_detail.pk}/?display=stock`;
|
var url = `/part/${row.sub_part_detail.pk}/?display=part-stock`;
|
||||||
var text = value;
|
var text = value;
|
||||||
|
|
||||||
if (value == null || value <= 0) {
|
if (value == null || value <= 0) {
|
||||||
|
@ -361,7 +361,7 @@ function loadCompanyTable(table, url, options={}) {
|
|||||||
field: 'parts_supplied',
|
field: 'parts_supplied',
|
||||||
title: '{% trans "Parts Supplied" %}',
|
title: '{% trans "Parts Supplied" %}',
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
return renderLink(value, `/company/${row.pk}/parts/`);
|
return renderLink(value, `/company/${row.pk}/?display=supplier-parts`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (options.pagetype == 'manufacturers') {
|
} else if (options.pagetype == 'manufacturers') {
|
||||||
@ -370,7 +370,7 @@ function loadCompanyTable(table, url, options={}) {
|
|||||||
field: 'parts_manufactured',
|
field: 'parts_manufactured',
|
||||||
title: '{% trans "Parts Manufactured" %}',
|
title: '{% trans "Parts Manufactured" %}',
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
return renderLink(value, `/company/${row.pk}/parts/`);
|
return renderLink(value, `/company/${row.pk}/?display=manufacturer-parts`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -469,6 +469,7 @@ function loadManufacturerPartTable(table, url, options) {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
original: params,
|
original: params,
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
|
sidePagination: 'server',
|
||||||
name: 'manufacturerparts',
|
name: 'manufacturerparts',
|
||||||
groupBy: false,
|
groupBy: false,
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
@ -724,6 +725,7 @@ function loadSupplierPartTable(table, url, options) {
|
|||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
original: params,
|
original: params,
|
||||||
|
sidePagination: 'server',
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
name: 'supplierparts',
|
name: 'supplierparts',
|
||||||
groupBy: false,
|
groupBy: false,
|
||||||
|
@ -94,7 +94,12 @@ function partFields(options={}) {
|
|||||||
},
|
},
|
||||||
default_location: {
|
default_location: {
|
||||||
},
|
},
|
||||||
default_supplier: {},
|
default_supplier: {
|
||||||
|
filters: {
|
||||||
|
part_detail: true,
|
||||||
|
supplier_detail: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
default_expiry: {
|
default_expiry: {
|
||||||
icon: 'fa-calendar-alt',
|
icon: 'fa-calendar-alt',
|
||||||
},
|
},
|
||||||
@ -315,6 +320,9 @@ function editPart(pk) {
|
|||||||
edit: true
|
edit: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Filter supplied parts by the Part ID
|
||||||
|
fields.default_supplier.filters.part = pk;
|
||||||
|
|
||||||
var groups = partGroups({});
|
var groups = partGroups({});
|
||||||
|
|
||||||
constructForm(url, {
|
constructForm(url, {
|
||||||
@ -338,6 +346,9 @@ function duplicatePart(pk, options={}) {
|
|||||||
duplicate: pk,
|
duplicate: pk,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove "default_supplier" field
|
||||||
|
delete fields['default_supplier'];
|
||||||
|
|
||||||
// If we are making a "variant" part
|
// If we are making a "variant" part
|
||||||
if (options.variant) {
|
if (options.variant) {
|
||||||
|
|
||||||
@ -528,7 +539,7 @@ function loadPartVariantTable(table, partId, options={}) {
|
|||||||
field: 'in_stock',
|
field: 'in_stock',
|
||||||
title: '{% trans "Stock" %}',
|
title: '{% trans "Stock" %}',
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
return renderLink(value, `/part/${row.pk}/?display=stock`);
|
return renderLink(value, `/part/${row.pk}/?display=part-stock`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -934,7 +945,7 @@ function loadPartTable(table, url, options={}) {
|
|||||||
title: '{% trans "Stock" %}',
|
title: '{% trans "Stock" %}',
|
||||||
searchable: false,
|
searchable: false,
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
var link = 'stock';
|
var link = '?display=part-stock';
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
// There IS stock available for this part
|
// There IS stock available for this part
|
||||||
@ -947,17 +958,17 @@ function loadPartTable(table, url, options={}) {
|
|||||||
} else if (row.on_order) {
|
} else if (row.on_order) {
|
||||||
// There is no stock available, but stock is on order
|
// There is no stock available, but stock is on order
|
||||||
value = `0<span class='label label-right label-primary'>{% trans "On Order" %}: ${row.on_order}</span>`;
|
value = `0<span class='label label-right label-primary'>{% trans "On Order" %}: ${row.on_order}</span>`;
|
||||||
link = 'orders';
|
link = '?display=purchase-orders';
|
||||||
} else if (row.building) {
|
} else if (row.building) {
|
||||||
// There is no stock available, but stock is being built
|
// There is no stock available, but stock is being built
|
||||||
value = `0<span class='label label-right label-info'>{% trans "Building" %}: ${row.building}</span>`;
|
value = `0<span class='label label-right label-info'>{% trans "Building" %}: ${row.building}</span>`;
|
||||||
link = 'builds';
|
link = '?display=build-orders';
|
||||||
} else {
|
} else {
|
||||||
// There is no stock available
|
// There is no stock available
|
||||||
value = `0<span class='label label-right label-danger'>{% trans "No Stock" %}</span>`;
|
value = `0<span class='label label-right label-danger'>{% trans "No Stock" %}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderLink(value, `/part/${row.pk}/${link}/`);
|
return renderLink(value, `/part/${row.pk}/${link}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ function loadStockTable(table, options) {
|
|||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
var link = `/supplier-part/${row.supplier_part}/?display=stock`;
|
var link = `/supplier-part/${row.supplier_part}/?display=part-stock`;
|
||||||
|
|
||||||
var text = '';
|
var text = '';
|
||||||
|
|
||||||
|
@ -181,6 +181,15 @@ function convertQueryParameters(params, filters) {
|
|||||||
if ('sortable' in params) {
|
if ('sortable' in params) {
|
||||||
delete params['sortable'];
|
delete params['sortable'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If "original_search" parameter is provided, add it to the "search"
|
||||||
|
if ('original_search' in params) {
|
||||||
|
var search = params['search'] || '';
|
||||||
|
|
||||||
|
params['search'] = search + ' ' + params['original_search'];
|
||||||
|
|
||||||
|
delete params['original_search'];
|
||||||
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ However, powerful business logic works in the background to ensure that stock tr
|
|||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
[![Docker Pulls](https://img.shields.io/docker/pulls/inventree/inventree)](https://hub.docker.com/r/inventree/inventree)
|
[![Docker Pulls](https://img.shields.io/docker/pulls/inventree/inventree)](https://hub.docker.com/r/inventree/inventree)
|
||||||
![Docker Build](https://github.com/inventree/inventree/actions/workflows/docker_build.yaml/badge.svg)
|
|
||||||
|
|
||||||
InvenTree is [available via Docker](https://hub.docker.com/r/inventree/inventree). Read the [docker guide](https://inventree.readthedocs.io/en/latest/start/docker/) for full details.
|
InvenTree is [available via Docker](https://hub.docker.com/r/inventree/inventree). Read the [docker guide](https://inventree.readthedocs.io/en/latest/start/docker/) for full details.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user