diff --git a/.gitignore b/.gitignore
index bb31aa7d3f..25c1195923 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
+inventree-env/
./build/
develop-eggs/
dist/
diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js
index 60978f8091..996f566fb6 100644
--- a/InvenTree/InvenTree/static/script/inventree/stock.js
+++ b/InvenTree/InvenTree/static/script/inventree/stock.js
@@ -378,8 +378,8 @@ function loadStockTrackingTable(table, options) {
html += "
" + row.notes + "";
}
- if (row.URL) {
- html += "
" + row.URL + "";
+ if (row.link) {
+ html += "
" + row.link + "";
}
return html;
diff --git a/InvenTree/build/fixtures/build.yaml b/InvenTree/build/fixtures/build.yaml
index d0fc30755a..c46afe625c 100644
--- a/InvenTree/build/fixtures/build.yaml
+++ b/InvenTree/build/fixtures/build.yaml
@@ -9,6 +9,7 @@
notes: 'Some simple notes'
status: 10 # PENDING
creation_date: '2019-03-16'
+ link: http://www.google.com
- model: build.build
fields:
diff --git a/InvenTree/build/forms.py b/InvenTree/build/forms.py
index 4f9384d34e..e060ff644d 100644
--- a/InvenTree/build/forms.py
+++ b/InvenTree/build/forms.py
@@ -25,7 +25,7 @@ class EditBuildForm(HelperForm):
'quantity',
'take_from',
'batch',
- 'URL',
+ 'link',
]
diff --git a/InvenTree/build/migrations/0011_auto_20200406_0123.py b/InvenTree/build/migrations/0011_auto_20200406_0123.py
new file mode 100644
index 0000000000..ba081c5e13
--- /dev/null
+++ b/InvenTree/build/migrations/0011_auto_20200406_0123.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.10 on 2020-04-06 01:23
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('build', '0010_auto_20200318_1027'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='build',
+ old_name='URL',
+ new_name='link',
+ ),
+ ]
diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py
index dae5789493..8730fd6700 100644
--- a/InvenTree/build/models.py
+++ b/InvenTree/build/models.py
@@ -38,7 +38,7 @@ class Build(models.Model):
batch: Batch code transferred to build parts (optional)
creation_date: Date the build was created (auto)
completion_date: Date the build was completed
- URL: External URL for extra information
+ link: External URL for extra information
notes: Text notes
"""
@@ -94,7 +94,7 @@ class Build(models.Model):
related_name='builds_completed'
)
- URL = InvenTreeURLField(blank=True, help_text=_('Link to external URL'))
+ link = InvenTreeURLField(blank=True, help_text=_('Link to external URL'))
notes = MarkdownxField(blank=True, help_text=_('Extra build notes'))
diff --git a/InvenTree/build/serializers.py b/InvenTree/build/serializers.py
index a7bb61a5cc..3eb3aee5be 100644
--- a/InvenTree/build/serializers.py
+++ b/InvenTree/build/serializers.py
@@ -30,7 +30,9 @@ class BuildSerializer(InvenTreeModelSerializer):
'quantity',
'status',
'status_text',
- 'notes']
+ 'notes',
+ 'link',
+ ]
read_only_fields = [
'status',
diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html
index 3c3be79b56..4011ca7dfb 100644
--- a/InvenTree/build/templates/build/detail.html
+++ b/InvenTree/build/templates/build/detail.html
@@ -11,15 +11,21 @@
- {% trans "Title" %} | {{ build.title }} |
+ |
+ {% trans "Title" %} |
+ {{ build.title }} |
- {% trans "Part" %} | {{ build.part.full_name }} |
+ |
+ {% trans "Part" %} |
+ {{ build.part.full_name }} |
+ |
{% trans "Quantity" %} | {{ build.quantity }} |
+ |
{% trans "Stock Source" %} |
{% if build.take_from %}
@@ -30,23 +36,32 @@
|
- {% trans "Status" %} | {% include "build_status.html" with build=build %} |
+ |
+ {% trans "Status" %} |
+ {% include "build_status.html" with build=build %} |
{% if build.batch %}
- {% trans "Batch" %} | {{ build.batch }} |
+ |
+ {% trans "Batch" %} |
+ {{ build.batch }} |
{% endif %}
-{% if build.URL %}
+{% if build.link %}
- {% trans "URL" %} | {{ build.URL }} |
+ |
+ {% trans "External Link" %} |
+ {{ build.link }} |
{% endif %}
- {% trans "Created" %} | {{ build.creation_date }} |
+ |
+ {% trans "Created" %} |
+ {{ build.creation_date }} |
{% if build.is_active %}
+ |
{% trans "Enough Parts?" %} |
{% if build.can_build %}
@@ -59,7 +74,9 @@
{% endif %}
{% if build.completion_date %}
|
- {% trans "Completed" %} | {{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %} |
+ |
+ {% trans "Completed" %} |
+ {{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %} |
{% endif %}
diff --git a/InvenTree/company/forms.py b/InvenTree/company/forms.py
index 3190149e24..85424eb3a1 100644
--- a/InvenTree/company/forms.py
+++ b/InvenTree/company/forms.py
@@ -53,7 +53,7 @@ class EditSupplierPartForm(HelperForm):
'description',
'manufacturer',
'MPN',
- 'URL',
+ 'link',
'note',
'base_cost',
'multiple',
diff --git a/InvenTree/company/migrations/0013_auto_20200406_0131.py b/InvenTree/company/migrations/0013_auto_20200406_0131.py
new file mode 100644
index 0000000000..6cac8f7678
--- /dev/null
+++ b/InvenTree/company/migrations/0013_auto_20200406_0131.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.10 on 2020-04-06 01:31
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('company', '0012_auto_20200318_1114'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='company',
+ old_name='URL',
+ new_name='link',
+ ),
+ migrations.RenameField(
+ model_name='supplierpart',
+ old_name='URL',
+ new_name='link',
+ ),
+ ]
diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py
index b079c084fc..6f14700184 100644
--- a/InvenTree/company/models.py
+++ b/InvenTree/company/models.py
@@ -63,7 +63,7 @@ class Company(models.Model):
address: Postal address
phone: contact phone number
email: contact email address
- URL: Secondary URL e.g. for link to internal Wiki page
+ link: Secondary URL e.g. for link to internal Wiki page
image: Company image / logo
notes: Extra notes about the company
is_customer: boolean value, is this company a customer
@@ -88,7 +88,7 @@ class Company(models.Model):
contact = models.CharField(max_length=100,
blank=True, help_text=_('Point of contact'))
- URL = InvenTreeURLField(blank=True, help_text=_('Link to external company information'))
+ link = InvenTreeURLField(blank=True, help_text=_('Link to external company information'))
image = models.ImageField(upload_to=rename_company_image, max_length=255, null=True, blank=True)
@@ -202,7 +202,7 @@ class SupplierPart(models.Model):
SKU: Stock keeping unit (supplier part number)
manufacturer: Manufacturer name
MPN: Manufacture part number
- URL: Link to external website for this part
+ link: Link to external website for this part
description: Descriptive notes field
note: Longer form note field
base_cost: Base charge added to order independent of quantity e.g. "Reeling Fee"
@@ -241,7 +241,7 @@ class SupplierPart(models.Model):
MPN = models.CharField(max_length=100, blank=True, help_text=_('Manufacturer part number'))
- URL = InvenTreeURLField(blank=True, help_text=_('URL for external supplier part link'))
+ link = InvenTreeURLField(blank=True, help_text=_('URL for external supplier part link'))
description = models.CharField(max_length=250, blank=True, help_text=_('Supplier part description'))
diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py
index 624a9b6157..161edd286e 100644
--- a/InvenTree/company/serializers.py
+++ b/InvenTree/company/serializers.py
@@ -47,7 +47,7 @@ class CompanySerializer(InvenTreeModelSerializer):
'address',
'email',
'contact',
- 'URL',
+ 'link',
'image',
'notes',
'is_customer',
@@ -91,7 +91,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer):
'manufacturer',
'description',
'MPN',
- 'URL',
+ 'link',
'pricing',
]
diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html
index 9e849e5a47..873d6747be 100644
--- a/InvenTree/company/templates/company/company_base.html
+++ b/InvenTree/company/templates/company/company_base.html
@@ -45,27 +45,37 @@ InvenTree | {% trans "Company" %} - {{ company.name }}
{% if company.website %}
- {% trans "Website" %} | {{ company.website }} |
+ |
+ {% trans "Website" %} |
+ {{ company.website }} |
{% endif %}
{% if company.address %}
- {% trans "Address" %} | {{ company.address }} |
+ |
+ {% trans "Address" %} |
+ {{ company.address }} |
{% endif %}
{% if company.phone %}
- {% trans "Phone" %} | {{ company.phone }} |
+ |
+ {% trans "Phone" %} |
+ {{ company.phone }} |
{% endif %}
{% if company.email %}
- {% trans "Email" %} | {{ company.email }} |
+ |
+ {% trans "Email" %} |
+ {{ company.email }} |
{% endif %}
{% if company.contact %}
- {% trans "Contact" %} | {{ company.contact }} |
+ |
+ {% trans "Contact" %} |
+ {{ company.contact }} |
{% endif %}
diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html
index 7eac2b7bfe..83c565943c 100644
--- a/InvenTree/company/templates/company/detail_part.html
+++ b/InvenTree/company/templates/company/detail_part.html
@@ -86,8 +86,8 @@
title: 'MPN',
},
{
- field: 'URL',
- title: '{% trans "URL" %}',
+ field: 'link',
+ title: '{% trans "Link" %}',
formatter: function(value, row, index, field) {
if (value) {
return renderLink(value, value);
diff --git a/InvenTree/company/templates/company/supplier_part_base.html b/InvenTree/company/templates/company/supplier_part_base.html
index 76f75094f7..33157ed67f 100644
--- a/InvenTree/company/templates/company/supplier_part_base.html
+++ b/InvenTree/company/templates/company/supplier_part_base.html
@@ -43,8 +43,8 @@ InvenTree | {% trans "Supplier Part" %}
{% trans "Supplier" %} | {{ part.supplier.name }} |
{% trans "SKU" %} | {{ part.SKU }} |
- {% if part.URL %}
- {% trans "URL" %} | {{ part.URL }} |
+ {% if part.link %}
+ {% trans "External Link" %} | {{ part.link }} |
{% endif %}
{% if part.description %}
{% trans "Description" %} | {{ part.description }} |
diff --git a/InvenTree/company/templates/company/supplier_part_detail.html b/InvenTree/company/templates/company/supplier_part_detail.html
index bb0dee177a..819b4964ba 100644
--- a/InvenTree/company/templates/company/supplier_part_detail.html
+++ b/InvenTree/company/templates/company/supplier_part_detail.html
@@ -20,8 +20,8 @@
{% trans "Supplier" %} | {{ part.supplier.name }} |
{% trans "SKU" %} | {{ part.SKU }} |
-{% if part.URL %}
- {% trans "URL" %} | {{ part.URL }} |
+{% if part.link %}
+ {% trans "External Link" %} | {{ part.link }} |
{% endif %}
{% if part.description %}
{% trans "Description" %} | {{ part.description }} |
diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py
index 2e8deb05c8..21fbd80326 100644
--- a/InvenTree/order/api.py
+++ b/InvenTree/order/api.py
@@ -78,7 +78,7 @@ class POList(generics.ListCreateAPIView):
'supplier__image',
'reference',
'description',
- 'URL',
+ 'link',
'status',
'notes',
'creation_date',
diff --git a/InvenTree/order/forms.py b/InvenTree/order/forms.py
index 05cedd9ad3..c110dfadca 100644
--- a/InvenTree/order/forms.py
+++ b/InvenTree/order/forms.py
@@ -70,7 +70,7 @@ class EditPurchaseOrderForm(HelperForm):
'reference',
'supplier',
'description',
- 'URL',
+ 'link',
]
diff --git a/InvenTree/order/migrations/0018_auto_20200406_0151.py b/InvenTree/order/migrations/0018_auto_20200406_0151.py
new file mode 100644
index 0000000000..1dfada77f6
--- /dev/null
+++ b/InvenTree/order/migrations/0018_auto_20200406_0151.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.10 on 2020-04-06 01:51
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('order', '0017_auto_20200331_1000'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='purchaseorder',
+ old_name='URL',
+ new_name='link',
+ ),
+ ]
diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py
index 88f1a8d188..9b569aa4cb 100644
--- a/InvenTree/order/models.py
+++ b/InvenTree/order/models.py
@@ -69,7 +69,7 @@ class Order(models.Model):
description = models.CharField(max_length=250, help_text=_('Order description'))
- URL = models.URLField(blank=True, help_text=_('Link to external page'))
+ link = models.URLField(blank=True, help_text=_('Link to external page'))
creation_date = models.DateField(blank=True, null=True)
diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py
index c4370015bc..ae6ace2148 100644
--- a/InvenTree/order/serializers.py
+++ b/InvenTree/order/serializers.py
@@ -21,7 +21,7 @@ class POSerializer(InvenTreeModelSerializer):
'supplier',
'reference',
'description',
- 'URL',
+ 'link',
'status',
'notes',
]
diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html
index 80a33fbfa8..6452f8ab2c 100644
--- a/InvenTree/order/templates/order/order_base.html
+++ b/InvenTree/order/templates/order/order_base.html
@@ -25,9 +25,6 @@ InvenTree | {{ order }}
{{ order }}
{{ order.description }}
- {% if order.URL %}
-
{{ order.URL }}
- {% endif %}
@@ -64,25 +61,37 @@ InvenTree | {{ order }}
{% trans "Purchase Order Details" %}
+ |
{% trans "Supplier" %} |
{{ order.supplier }} |
+ |
{% trans "Status" %} |
{% include "order/order_status.html" %} |
+ {% if order.link %}
+ |
+ External Link |
+ {{ order.link }} |
+
+ {% endif %}
+
+ |
{% trans "Created" %} |
{{ order.creation_date }}{{ order.created_by }} |
{% if order.issue_date %}
+ |
{% trans "Issued" %} |
{{ order.issue_date }} |
{% endif %}
{% if order.status == OrderStatus.COMPLETE %}
+ |
{% trans "Received" %} |
{{ order.complete_date }}{{ order.received_by }} |
diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py
index e032c73eeb..7bb31af14d 100644
--- a/InvenTree/part/api.py
+++ b/InvenTree/part/api.py
@@ -200,7 +200,7 @@ class PartList(generics.ListCreateAPIView):
'description',
'keywords',
'is_template',
- 'URL',
+ 'link',
'units',
'minimum_stock',
'trackable',
@@ -225,11 +225,17 @@ class PartList(generics.ListCreateAPIView):
# Use the 'thumbnail' image here instead of the full-size image
# Note: The full-size image is used when requesting the /api/part// endpoint
- fn, ext = os.path.splitext(img)
- thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
+ if img:
+ fn, ext = os.path.splitext(img)
- item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
+ thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
+
+ thumb = os.path.join(settings.MEDIA_URL, thumb)
+ else:
+ thumb = ''
+
+ item['thumbnail'] = thumb
del item['image']
@@ -243,12 +249,6 @@ class PartList(generics.ListCreateAPIView):
else:
item['category__name'] = None
- # Rename "URL" to "link" to distinguish from lower-case "url",
- # which is the web address of the item itself
- if 'URL' in item.keys():
- item['link'] = item['URL']
- del item['URL']
-
return Response(data)
def get_queryset(self):
diff --git a/InvenTree/part/fixtures/part.yaml b/InvenTree/part/fixtures/part.yaml
index 8f4963cbad..117763be84 100644
--- a/InvenTree/part/fixtures/part.yaml
+++ b/InvenTree/part/fixtures/part.yaml
@@ -6,6 +6,7 @@
name: 'M2x4 LPHS'
description: 'M2x4 low profile head screw'
category: 8
+ link: www.acme.com/parts/m2x4lphs
- model: part.part
pk: 2
diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py
index 5adf1e08dd..332e9b6611 100644
--- a/InvenTree/part/forms.py
+++ b/InvenTree/part/forms.py
@@ -120,7 +120,7 @@ class EditPartForm(HelperForm):
'keywords',
'variant_of',
'is_template',
- 'URL',
+ 'link',
'default_location',
'default_supplier',
'units',
diff --git a/InvenTree/part/migrations/0034_auto_20200404_1238.py b/InvenTree/part/migrations/0034_auto_20200404_1238.py
index 95b3cd2b96..e292202b68 100644
--- a/InvenTree/part/migrations/0034_auto_20200404_1238.py
+++ b/InvenTree/part/migrations/0034_auto_20200404_1238.py
@@ -1,6 +1,7 @@
# Generated by Django 2.2.10 on 2020-04-04 12:38
from django.db import migrations
+from django.db.utils import OperationalError
from part.models import Part
from stdimage.utils import render_variations
@@ -11,11 +12,13 @@ def create_thumbnails(apps, schema_editor):
Create thumbnails for all existing Part images.
"""
- for part in Part.objects.all():
- # Render thumbnail for each existing Part
- if part.image:
- part.image.render_variations()
-
+ try:
+ for part in Part.objects.all():
+ # Render thumbnail for each existing Part
+ if part.image:
+ part.image.render_variations()
+ except OperationalError:
+ print("Error - could not generate Part thumbnails")
class Migration(migrations.Migration):
diff --git a/InvenTree/part/migrations/0035_auto_20200406_0045.py b/InvenTree/part/migrations/0035_auto_20200406_0045.py
new file mode 100644
index 0000000000..92f0472880
--- /dev/null
+++ b/InvenTree/part/migrations/0035_auto_20200406_0045.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.10 on 2020-04-06 00:45
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('part', '0034_auto_20200404_1238'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='part',
+ old_name='URL',
+ new_name='link',
+ ),
+ ]
diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py
index 92dd8a0d68..da0bff16b8 100644
--- a/InvenTree/part/models.py
+++ b/InvenTree/part/models.py
@@ -214,7 +214,7 @@ class Part(models.Model):
IPN: Internal part number (optional)
revision: Part revision
is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem
- URL: Link to an external page with more information about this part (e.g. internal Wiki)
+ link: Link to an external page with more information about this part (e.g. internal Wiki)
image: Image of this part
default_location: Where the item is normally stored (may be null)
default_supplier: The default SupplierPart which should be used to procure and stock this part
@@ -383,7 +383,7 @@ class Part(models.Model):
revision = models.CharField(max_length=100, blank=True, help_text=_('Part revision or version number'))
- URL = InvenTreeURLField(blank=True, help_text=_('Link to extenal URL'))
+ link = InvenTreeURLField(blank=True, help_text=_('Link to extenal URL'))
image = StdImageField(
upload_to=rename_part_image,
diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py
index 9e97cad84f..d5270cabb2 100644
--- a/InvenTree/part/serializers.py
+++ b/InvenTree/part/serializers.py
@@ -47,7 +47,7 @@ class PartBriefSerializer(InvenTreeModelSerializer):
""" Serializer for Part (brief detail) """
url = serializers.CharField(source='get_absolute_url', read_only=True)
- image_url = serializers.CharField(source='get_thumbnail_url', read_only=True)
+ thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
@staticmethod
def setup_eager_loading(queryset):
@@ -66,7 +66,7 @@ class PartBriefSerializer(InvenTreeModelSerializer):
'description',
'total_stock',
'available_stock',
- 'image_url',
+ 'thumbnail',
'active',
'assembly',
'virtual',
@@ -86,7 +86,6 @@ class PartSerializer(InvenTreeModelSerializer):
on_order = serializers.FloatField(read_only=True)
thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
url = serializers.CharField(source='get_absolute_url', read_only=True)
- link = serializers.CharField(source='URL')
used_in = serializers.IntegerField(source='used_in_count', read_only=True)
@staticmethod
diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html
index b41e470bd2..64e0bed5bc 100644
--- a/InvenTree/part/templates/part/detail.html
+++ b/InvenTree/part/templates/part/detail.html
@@ -60,11 +60,11 @@
{% endif %}
- {% if part.URL %}
+ {% if part.link %}
|
- {% trans "Link" %} |
- {{ part.URL }} |
+ {% trans "External Link" %} |
+ {{ part.link }} |
{% endif %}
{% if part.default_location %}
diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html
index 7eb2f1dc5a..b75b01cb12 100644
--- a/InvenTree/part/templates/part/part_base.html
+++ b/InvenTree/part/templates/part/part_base.html
@@ -72,14 +72,16 @@
{% if part.IPN %}
+ |
{% trans "IPN" %} |
{{ part.IPN }} |
{% endif %}
- {% if part.URL %}
+ {% if part.link %}
- {% trans "URL" %} |
- {{ part.URL }} |
+ |
+ {% trans "External Link" %} |
+ {{ part.link }} |
{% endif %}
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
index da4b757009..8f1311b96a 100644
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -1388,8 +1388,6 @@ class BomExport(AjaxView):
url += '?file_format=' + fmt
url += '&cascade=' + str(cascade)
- print("URL:", url)
-
data = {
'form_valid': part is not None,
'url': url,
diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py
index 3c3e5acce6..571c856857 100644
--- a/InvenTree/stock/api.py
+++ b/InvenTree/stock/api.py
@@ -59,6 +59,22 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
serializer_class = StockItemSerializer
permission_classes = (permissions.IsAuthenticated,)
+ def get_serializer(self, *args, **kwargs):
+
+ try:
+ kwargs['part_detail'] = str2bool(self.request.GET.get('part_detail', False))
+ except AttributeError:
+ pass
+
+ try:
+ kwargs['location_detail'] = str2bool(self.request.GET.get('location_detail', False))
+ except AttributeError:
+ pass
+
+ kwargs['context'] = self.get_serializer_context()
+
+ return self.serializer_class(*args, **kwargs)
+
class StockFilter(FilterSet):
""" FilterSet for advanced stock filtering.
@@ -317,6 +333,7 @@ class StockList(generics.ListCreateAPIView):
'batch',
'status',
'notes',
+ 'link',
'location',
'location__name',
'location__description',
@@ -340,12 +357,17 @@ class StockList(generics.ListCreateAPIView):
img = item['part__image']
- # Use the thumbnail image instead
- fn, ext = os.path.splitext(img)
+ if img:
+ # Use the thumbnail image instead
+ fn, ext = os.path.splitext(img)
- thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
+ thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
- item['part__thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
+ thumb = os.path.join(settings.MEDIA_URL, thumb)
+ else:
+ thumb = ''
+
+ item['part__thumbnail'] = thumb
del item['part__image']
diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py
index ca206ca49d..fef6ecc7a5 100644
--- a/InvenTree/stock/forms.py
+++ b/InvenTree/stock/forms.py
@@ -42,9 +42,9 @@ class CreateStockItemForm(HelperForm):
'quantity',
'batch',
'serial_numbers',
+ 'link',
'delete_on_deplete',
'status',
- 'URL',
]
# Custom clean to prevent complex StockItem.clean() logic from running (yet)
@@ -161,7 +161,7 @@ class EditStockItemForm(HelperForm):
'serial',
'batch',
'status',
- 'URL',
+ 'link',
'delete_on_deplete',
]
@@ -176,5 +176,5 @@ class TrackingEntryForm(HelperForm):
fields = [
'title',
'notes',
- 'URL',
+ 'link',
]
diff --git a/InvenTree/stock/migrations/0024_auto_20200405_2239.py b/InvenTree/stock/migrations/0024_auto_20200405_2239.py
new file mode 100644
index 0000000000..c285b4a813
--- /dev/null
+++ b/InvenTree/stock/migrations/0024_auto_20200405_2239.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.2.10 on 2020-04-05 22:39
+
+import InvenTree.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('stock', '0023_auto_20200318_1027'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='stockitem',
+ name='URL',
+ field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', max_length=125),
+ ),
+ ]
diff --git a/InvenTree/stock/migrations/0025_auto_20200405_2243.py b/InvenTree/stock/migrations/0025_auto_20200405_2243.py
new file mode 100644
index 0000000000..0eab1c813b
--- /dev/null
+++ b/InvenTree/stock/migrations/0025_auto_20200405_2243.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.10 on 2020-04-05 22:43
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('stock', '0024_auto_20200405_2239'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='stockitem',
+ old_name='URL',
+ new_name='link',
+ ),
+ migrations.RenameField(
+ model_name='stockitemtracking',
+ old_name='URL',
+ new_name='link',
+ ),
+ ]
diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py
index 64353d948d..554fb00495 100644
--- a/InvenTree/stock/models.py
+++ b/InvenTree/stock/models.py
@@ -114,7 +114,7 @@ class StockItem(MPTTModel):
quantity: Number of stocked units
batch: Batch number for this StockItem
serial: Unique serial number for this StockItem
- URL: Optional URL to link to external resource
+ link: Optional URL to link to external resource
updated: Date that this stock item was last updated (auto)
stocktake_date: Date of last stocktake for this item
stocktake_user: User that performed the most recent stocktake
@@ -328,7 +328,7 @@ class StockItem(MPTTModel):
serial = models.PositiveIntegerField(blank=True, null=True,
help_text=_('Serial number for this item'))
- URL = InvenTreeURLField(max_length=125, blank=True)
+ link = InvenTreeURLField(max_length=125, blank=True, help_text=_("Link to external URL"))
batch = models.CharField(max_length=100, blank=True, null=True,
help_text=_('Batch code for this stock item'))
@@ -427,7 +427,7 @@ class StockItem(MPTTModel):
quantity=self.quantity,
date=datetime.now().date(),
notes=notes,
- URL=url,
+ link=url,
system=system
)
@@ -793,7 +793,7 @@ class StockItemTracking(models.Model):
date: Date that this tracking info was created
title: Title of this tracking info (generated by system)
notes: Associated notes (input by user)
- URL: Optional URL to external page
+ link: Optional URL to external page
user: The user associated with this tracking info
quantity: The StockItem quantity at this point in time
"""
@@ -811,7 +811,7 @@ class StockItemTracking(models.Model):
notes = models.CharField(blank=True, max_length=512, help_text=_('Entry notes'))
- URL = InvenTreeURLField(blank=True, help_text=_('Link to external page for further information'))
+ link = InvenTreeURLField(blank=True, help_text=_('Link to external page for further information'))
user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py
index f84667e352..de9e8c50ce 100644
--- a/InvenTree/stock/serializers.py
+++ b/InvenTree/stock/serializers.py
@@ -59,6 +59,8 @@ class StockItemSerializer(InvenTreeModelSerializer):
part_name = serializers.CharField(source='get_part_name', read_only=True)
+ part_image = serializers.CharField(source='part__image', read_only=True)
+
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
@@ -78,21 +80,23 @@ class StockItemSerializer(InvenTreeModelSerializer):
class Meta:
model = StockItem
fields = [
- 'pk',
- 'url',
- 'part',
- 'part_name',
- 'part_detail',
- 'supplier_part',
+ 'batch',
+ 'in_stock',
+ 'link',
'location',
'location_detail',
- 'in_stock',
+ 'notes',
+ 'part',
+ 'part_detail',
+ 'part_name',
+ 'part_image',
+ 'pk',
'quantity',
'serial',
- 'batch',
+ 'supplier_part',
'status',
'status_text',
- 'notes',
+ 'url',
]
""" These fields are read-only in this context.
@@ -152,7 +156,7 @@ class StockTrackingSerializer(InvenTreeModelSerializer):
'date',
'title',
'notes',
- 'URL',
+ 'link',
'quantity',
'user',
'system',
diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html
index 3f5fdca9ad..9ef0762a07 100644
--- a/InvenTree/stock/templates/stock/item_base.html
+++ b/InvenTree/stock/templates/stock/item_base.html
@@ -74,6 +74,7 @@
+ |
Part |
{% include "hover_image.html" with image=item.part.image hover=True %}
@@ -82,71 +83,84 @@
|
{% if item.belongs_to %}
+ |
{% trans "Belongs To" %} |
{{ item.belongs_to }} |
{% elif item.location %}
+ |
{% trans "Location" %} |
{{ item.location.name }} |
{% endif %}
{% if item.serialized %}
+ |
{% trans "Serial Number" %} |
{{ item.serial }} |
{% else %}
+ |
{% trans "Quantity" %} |
{% decimal item.quantity %} {% if item.part.units %}{{ item.part.units }}{% endif %} |
{% endif %}
{% if item.batch %}
+ |
{% trans "Batch" %} |
{{ item.batch }} |
{% endif %}
{% if item.build %}
+ |
{% trans "Build" %} |
{{ item.build }} |
{% endif %}
{% if item.purchase_order %}
+ |
{% trans "Purchase Order" %} |
{{ item.purchase_order }} |
{% endif %}
{% if item.customer %}
+ |
{% trans "Customer" %} |
{{ item.customer.name }} |
{% endif %}
- {% if item.URL %}
+ {% if item.link %}
- {% trans "URL" %} |
- {{ item.URL }} |
+
+ | {% trans "External Link" %} |
+ {{ item.link }} |
{% endif %}
{% if item.supplier_part %}
+ |
{% trans "Supplier" %} |
{{ item.supplier_part.supplier.name }} |
+ |
{% trans "Supplier Part" %} |
{{ item.supplier_part.SKU }} |
{% endif %}
+ |
{% trans "Last Updated" %} |
{{ item.updated }} |
+ |
{% trans "Last Stocktake" %} |
{% if item.stocktake_date %}
{{ item.stocktake_date }} {{ item.stocktake_user }} |
@@ -155,6 +169,7 @@
{% endif %}
+ |
{% trans "Status" %} |
{{ item.get_status_display }} |
diff --git a/InvenTree/stock/views.py b/InvenTree/stock/views.py
index 4ac415ef23..24c61fd89b 100644
--- a/InvenTree/stock/views.py
+++ b/InvenTree/stock/views.py
@@ -934,7 +934,7 @@ class StockItemCreate(AjaxCreateView):
batch=form_data.get('batch'),
delete_on_deplete=False,
status=form_data.get('status'),
- URL=form_data.get('URL'),
+ link=form_data.get('link'),
)
item.save(user=request.user)