From 2530313e68a1cf897081013b9f619f640598a41f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 08:38:10 +1000 Subject: [PATCH 1/9] Add part_detail and location_detail to the StockItem detail class --- InvenTree/stock/api.py | 12 ++++++++++++ InvenTree/stock/serializers.py | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 53d4b15d13..230f9bde4b 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -59,6 +59,18 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView): serializer_class = StockItemSerializer permission_classes = (permissions.IsAuthenticated,) + def get_serializer(self, *args, **kwargs): + + part_detail = str2bool(self.request.GET.get('part_detail', False)) + loc_detail = str2bool(self.request.GET.get('location_detail', False)) + + kwargs['part_detail'] = part_detail + kwargs['location_detail'] = loc_detail + + kwargs['context'] = self.get_serializer_context() + + return self.serializer_class(*args, **kwargs) + class StockFilter(FilterSet): """ FilterSet for advanced stock filtering. diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index f84667e352..d03b1f8770 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) @@ -81,8 +83,9 @@ class StockItemSerializer(InvenTreeModelSerializer): 'pk', 'url', 'part', - 'part_name', 'part_detail', + 'part_name', + 'part_image', 'supplier_part', 'location', 'location_detail', From bd407cd22667a45cba5848201367384bdb020afc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 10:43:06 +1000 Subject: [PATCH 2/9] 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 %} + From b28487760ac074a51450c6e9937c2520adfa3cae Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 11:16:39 +1000 Subject: [PATCH 3/9] Rename Part.URL -> part.link - Previous migration needed some tweaking to get it to run... because.. why? - It seems to pass when running manage.py migrate but fails when running manage.py test - Stumped on this one --- .gitignore | 1 + InvenTree/part/api.py | 8 +------- InvenTree/part/forms.py | 2 +- .../part/migrations/0034_auto_20200404_1238.py | 13 ++++++++----- .../part/migrations/0035_auto_20200406_0045.py | 18 ++++++++++++++++++ InvenTree/part/models.py | 4 ++-- InvenTree/part/serializers.py | 1 - InvenTree/part/templates/part/detail.html | 6 +++--- InvenTree/part/templates/part/part_base.html | 8 +++++--- InvenTree/part/views.py | 2 -- 10 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 InvenTree/part/migrations/0035_auto_20200406_0045.py 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/part/api.py b/InvenTree/part/api.py index 9b73f68973..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', @@ -249,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/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..18d8fbd8c8 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -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 %} - - + + {% 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 @@
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 }}
{% trans "Link" %}{{ part.URL }}{% trans "External Link" %}{{ part.link }}
{% if part.IPN %} + {% endif %} - {% if part.URL %} + {% if 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, From bbe714c8f7a5a69b5cf42a128f6096e2973f43c3 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 11:21:34 +1000 Subject: [PATCH 4/9] Bugs! Thanks, unit testing --- InvenTree/stock/api.py | 12 ++++++++---- InvenTree/stock/models.py | 2 +- InvenTree/stock/views.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 5bd11ef196..571c856857 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -61,11 +61,15 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView): def get_serializer(self, *args, **kwargs): - part_detail = str2bool(self.request.GET.get('part_detail', False)) - loc_detail = str2bool(self.request.GET.get('location_detail', False)) + try: + kwargs['part_detail'] = str2bool(self.request.GET.get('part_detail', False)) + except AttributeError: + pass - kwargs['part_detail'] = part_detail - kwargs['location_detail'] = loc_detail + try: + kwargs['location_detail'] = str2bool(self.request.GET.get('location_detail', False)) + except AttributeError: + pass kwargs['context'] = self.get_serializer_context() diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index f6ccd04121..554fb00495 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -427,7 +427,7 @@ class StockItem(MPTTModel): quantity=self.quantity, date=datetime.now().date(), notes=notes, - URL=url, + link=url, system=system ) 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) From 789712acbe2e848b1ee96795718acebc26b0b7b6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 11:28:35 +1000 Subject: [PATCH 5/9] Rename Build.URL -> Build.link --- InvenTree/build/fixtures/build.yaml | 1 + InvenTree/build/forms.py | 2 +- .../migrations/0011_auto_20200406_0123.py | 18 ++++++++++ InvenTree/build/models.py | 4 +-- InvenTree/build/serializers.py | 4 ++- InvenTree/build/templates/build/detail.html | 33 ++++++++++++++----- InvenTree/part/fixtures/part.yaml | 1 + 7 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 InvenTree/build/migrations/0011_auto_20200406_0123.py 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 "IPN" %} {{ part.IPN }}
{% trans "URL" %}{{ part.URL }}{% trans "External Link" %}{{ part.link }}
- + + + - + + + + + - + + + {% if build.batch %} - + + + {% endif %} -{% if build.URL %} +{% if build.link %} - + + + {% endif %} - + + + {% if build.is_active %} + - + + + {% endif %}
{% 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 %}
{% trans "Batch" %}{{ build.batch }}{% trans "Batch" %}{{ build.batch }}
{% trans "URL" %}{{ build.URL }}{% trans "External Link" %}{{ build.link }}
{% trans "Created" %}{{ build.creation_date }}{% trans "Created" %}{{ build.creation_date }}
{% 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 %}
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 From a306ad0bc384ef6326b0ebd07dfc1ab0914d6afb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 11:36:25 +1000 Subject: [PATCH 6/9] Alter "URL" to "link" for Company models --- InvenTree/company/forms.py | 2 +- .../migrations/0013_auto_20200406_0131.py | 23 +++++++++++++++++++ InvenTree/company/models.py | 8 +++---- InvenTree/company/serializers.py | 4 ++-- .../templates/company/company_base.html | 20 ++++++++++++---- .../templates/company/detail_part.html | 4 ++-- .../templates/company/supplier_part_base.html | 4 ++-- .../company/supplier_part_detail.html | 4 ++-- 8 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 InvenTree/company/migrations/0013_auto_20200406_0131.py 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 %} - + + + {% endif %} {% if company.address %} - + + + {% endif %} {% if company.phone %} - + + + {% endif %} {% if company.email %} - + + + {% endif %} {% if company.contact %} - + + + {% endif %}
{% trans "Website" %}{{ company.website }}{% trans "Website" %}{{ company.website }}
{% trans "Address" %}{{ company.address }}{% trans "Address" %}{{ company.address }}
{% trans "Phone" %}{{ company.phone }}{% trans "Phone" %}{{ company.phone }}
{% trans "Email" %}{{ company.email }}{% trans "Email" %}{{ company.email }}
{% trans "Contact" %}{{ company.contact }}{% trans "Contact" %}{{ company.contact }}
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 }} From 87a09a7220cf1a283554e3a696620798e99bf9cf Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 11:56:52 +1000 Subject: [PATCH 7/9] Rename Order.URL to Order.link --- InvenTree/order/forms.py | 2 +- .../migrations/0018_auto_20200406_0151.py | 18 ++++++++++++++++++ InvenTree/order/models.py | 2 +- InvenTree/order/serializers.py | 2 +- .../order/templates/order/order_base.html | 15 ++++++++++++--- 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 InvenTree/order/migrations/0018_auto_20200406_0151.py 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" %}

+ + + {% if order.link %} + + + + + {% endif %} + + {% if order.issue_date %} + {% endif %} {% if order.status == OrderStatus.COMPLETE %} + From 535f1994b19c6f97503cf8fed968bc75a99d317e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 12:02:23 +1000 Subject: [PATCH 8/9] Fix order API reference --- InvenTree/order/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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', From 92cb7211ced884769922831b8f2e3e815594b838 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 6 Apr 2020 12:57:04 +1000 Subject: [PATCH 9/9] Rename 'image_url' to 'thumbnail' in PartBrief API --- InvenTree/part/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 18d8fbd8c8..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',
{% trans "Supplier" %} {{ order.supplier }}
{% trans "Status" %} {% include "order/order_status.html" %}
External Link{{ order.link }}
{% trans "Created" %} {{ order.creation_date }}{{ order.created_by }}
{% trans "Issued" %} {{ order.issue_date }}
{% trans "Received" %} {{ order.complete_date }}{{ order.received_by }}