From bd407cd22667a45cba5848201367384bdb020afc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 10:43:06 +1000 Subject: [PATCH] Rename "URL" to "link" for StockItem and StockItemTracking models --- .../static/script/inventree/stock.js | 4 ++-- InvenTree/stock/api.py | 1 + InvenTree/stock/forms.py | 6 ++--- .../migrations/0024_auto_20200405_2239.py | 19 +++++++++++++++ .../migrations/0025_auto_20200405_2243.py | 23 +++++++++++++++++++ InvenTree/stock/models.py | 8 +++---- InvenTree/stock/serializers.py | 19 +++++++-------- .../stock/templates/stock/item_base.html | 21 ++++++++++++++--- 8 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 InvenTree/stock/migrations/0024_auto_20200405_2239.py create mode 100644 InvenTree/stock/migrations/0025_auto_20200405_2243.py 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/stock/api.py b/InvenTree/stock/api.py index 230f9bde4b..5bd11ef196 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -329,6 +329,7 @@ class StockList(generics.ListCreateAPIView): 'batch', 'status', 'notes', + 'link', 'location', 'location__name', 'location__description', 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..f6ccd04121 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')) @@ -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 d03b1f8770..de9e8c50ce 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -80,22 +80,23 @@ class StockItemSerializer(InvenTreeModelSerializer): class Meta: model = StockItem fields = [ - 'pk', - 'url', + 'batch', + 'in_stock', + 'link', + 'location', + 'location_detail', + 'notes', 'part', 'part_detail', 'part_name', 'part_image', - 'supplier_part', - 'location', - 'location_detail', - 'in_stock', + 'pk', 'quantity', 'serial', - 'batch', + 'supplier_part', 'status', 'status_text', - 'notes', + 'url', ] """ These fields are read-only in this context. @@ -155,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 @@
+ {% if item.belongs_to %} + {% elif item.location %} + {% endif %} {% if item.serialized %} + {% else %} + {% endif %} {% if item.batch %} + {% endif %} {% if item.build %} + {% endif %} {% if item.purchase_order %} + {% endif %} {% if item.customer %} + {% endif %} - {% if item.URL %} + {% if item.link %} - - + + {% endif %} {% if item.supplier_part %} + + {% endif %} + + {% if item.stocktake_date %} @@ -155,6 +169,7 @@ {% endif %} +
Part {% include "hover_image.html" with image=item.part.image hover=True %} @@ -82,71 +83,84 @@
{% trans "Belongs To" %} {{ item.belongs_to }}
{% trans "Location" %} {{ item.location.name }}
{% trans "Serial Number" %} {{ item.serial }}
{% trans "Quantity" %} {% decimal item.quantity %} {% if item.part.units %}{{ item.part.units }}{% endif %}
{% trans "Batch" %} {{ item.batch }}
{% trans "Build" %} {{ item.build }}
{% trans "Purchase Order" %} {{ item.purchase_order }}
{% trans "Customer" %} {{ item.customer.name }}
{% trans "URL" %}{{ item.URL }} + {% trans "External Link" %}{{ item.link }}
{% trans "Supplier" %} {{ item.supplier_part.supplier.name }}
{% trans "Supplier Part" %} {{ item.supplier_part.SKU }}
{% trans "Last Updated" %} {{ item.updated }}
{% trans "Last Stocktake" %}{{ item.stocktake_date }} {{ item.stocktake_user }}
{% trans "Status" %} {{ item.get_status_display }}