mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #698 from SchrodingersGat/stock-api
Further API work
This commit is contained in:
commit
7c2af32b38
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ __pycache__/
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
inventree-env/
|
||||
./build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
|
@ -378,8 +378,8 @@ function loadStockTrackingTable(table, options) {
|
||||
html += "<br><i>" + row.notes + "</i>";
|
||||
}
|
||||
|
||||
if (row.URL) {
|
||||
html += "<br><a href='" + row.URL + "'>" + row.URL + "</a>";
|
||||
if (row.link) {
|
||||
html += "<br><a href='" + row.link + "'>" + row.link + "</a>";
|
||||
}
|
||||
|
||||
return html;
|
||||
|
@ -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:
|
||||
|
@ -25,7 +25,7 @@ class EditBuildForm(HelperForm):
|
||||
'quantity',
|
||||
'take_from',
|
||||
'batch',
|
||||
'URL',
|
||||
'link',
|
||||
]
|
||||
|
||||
|
||||
|
18
InvenTree/build/migrations/0011_auto_20200406_0123.py
Normal file
18
InvenTree/build/migrations/0011_auto_20200406_0123.py
Normal file
@ -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',
|
||||
),
|
||||
]
|
@ -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'))
|
||||
|
||||
|
@ -30,7 +30,9 @@ class BuildSerializer(InvenTreeModelSerializer):
|
||||
'quantity',
|
||||
'status',
|
||||
'status_text',
|
||||
'notes']
|
||||
'notes',
|
||||
'link',
|
||||
]
|
||||
|
||||
read_only_fields = [
|
||||
'status',
|
||||
|
@ -11,15 +11,21 @@
|
||||
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td>{% trans "Title" %}</td><td>{{ build.title }}</td>
|
||||
<td></td>
|
||||
<td>{% trans "Title" %}</td>
|
||||
<td>{{ build.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Part" %}</td><td><a href="{% url 'part-build' build.part.id %}">{{ build.part.full_name }}</a></td>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>{% trans "Part" %}</td>
|
||||
<td><a href="{% url 'part-build' build.part.id %}">{{ build.part.full_name }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Quantity" %}</td><td>{{ build.quantity }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Stock Source" %}</td>
|
||||
<td>
|
||||
{% if build.take_from %}
|
||||
@ -30,23 +36,32 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans "Status" %}</td><td>{% include "build_status.html" with build=build %}</td>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{% include "build_status.html" with build=build %}</td>
|
||||
</tr>
|
||||
{% if build.batch %}
|
||||
<tr>
|
||||
<td>{% trans "Batch" %}</td><td>{{ build.batch }}</td>
|
||||
<td></td>
|
||||
<td>{% trans "Batch" %}</td>
|
||||
<td>{{ build.batch }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if build.URL %}
|
||||
{% if build.link %}
|
||||
<tr>
|
||||
<td>{% trans "URL" %}</td><td><a href="{{ build.URL }}">{{ build.URL }}</a></td>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ build.link }}">{{ build.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>{% trans "Created" %}</td><td>{{ build.creation_date }}</td>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Created" %}</td>
|
||||
<td>{{ build.creation_date }}</td>
|
||||
</tr>
|
||||
{% if build.is_active %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Enough Parts?" %}</td>
|
||||
<td>
|
||||
{% if build.can_build %}
|
||||
@ -59,7 +74,9 @@
|
||||
{% endif %}
|
||||
{% if build.completion_date %}
|
||||
<tr>
|
||||
<td>{% trans "Completed" %}</td><td>{{ build.completion_date }}{% if build.completed_by %}<span class='badge'>{{ build.completed_by }}</span>{% endif %}</td>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Completed" %}</td>
|
||||
<td>{{ build.completion_date }}{% if build.completed_by %}<span class='badge'>{{ build.completed_by }}</span>{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
@ -53,7 +53,7 @@ class EditSupplierPartForm(HelperForm):
|
||||
'description',
|
||||
'manufacturer',
|
||||
'MPN',
|
||||
'URL',
|
||||
'link',
|
||||
'note',
|
||||
'base_cost',
|
||||
'multiple',
|
||||
|
23
InvenTree/company/migrations/0013_auto_20200406_0131.py
Normal file
23
InvenTree/company/migrations/0013_auto_20200406_0131.py
Normal file
@ -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',
|
||||
),
|
||||
]
|
@ -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'))
|
||||
|
||||
|
@ -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',
|
||||
]
|
||||
|
||||
|
@ -45,27 +45,37 @@ InvenTree | {% trans "Company" %} - {{ company.name }}
|
||||
<table class="table">
|
||||
{% if company.website %}
|
||||
<tr>
|
||||
<td>{% trans "Website" %}</td><td><a href="{{ company.website }}">{{ company.website }}</a></td>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "Website" %}</td>
|
||||
<td><a href="{{ company.website }}">{{ company.website }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if company.address %}
|
||||
<tr>
|
||||
<td>{% trans "Address" %}</td><td>{{ company.address }}</td>
|
||||
<td><span class='fas fa-map-marked-alt'></span></td>
|
||||
<td>{% trans "Address" %}</td>
|
||||
<td>{{ company.address }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if company.phone %}
|
||||
<tr>
|
||||
<td>{% trans "Phone" %}</td><td>{{ company.phone }}</td>
|
||||
<td><span class='fas fa-phone'></span></td>
|
||||
<td>{% trans "Phone" %}</td>
|
||||
<td>{{ company.phone }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if company.email %}
|
||||
<tr>
|
||||
<td>{% trans "Email" %}</td><td>{{ company.email }}</td>
|
||||
<td><span class='fas fa-at'></span></td>
|
||||
<td>{% trans "Email" %}</td>
|
||||
<td>{{ company.email }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if company.contact %}
|
||||
<tr>
|
||||
<td>{% trans "Contact" %}</td><td>{{ company.contact }}</td>
|
||||
<td><span class='fas fa-user'></span></td>
|
||||
<td>{% trans "Contact" %}</td>
|
||||
<td>{{ company.contact }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
@ -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);
|
||||
|
@ -43,8 +43,8 @@ InvenTree | {% trans "Supplier Part" %}
|
||||
</tr>
|
||||
<tr><td>{% trans "Supplier" %}</td><td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>{% trans "SKU" %}</td><td>{{ part.SKU }}</tr></tr>
|
||||
{% if part.URL %}
|
||||
<tr><td>{% trans "URL" %}</td><td><a href="{{ part.URL }}">{{ part.URL }}</a></td></tr>
|
||||
{% if part.link %}
|
||||
<tr><td>{% trans "External Link" %}</td><td><a href="{{ part.link }}">{{ part.link }}</a></td></tr>
|
||||
{% endif %}
|
||||
{% if part.description %}
|
||||
<tr><td>{% trans "Description" %}</td><td>{{ part.description }}</td></tr>
|
||||
|
@ -20,8 +20,8 @@
|
||||
</tr>
|
||||
<tr><td>{% trans "Supplier" %}</td><td><a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></td></tr>
|
||||
<tr><td>{% trans "SKU" %}</td><td>{{ part.SKU }}</tr></tr>
|
||||
{% if part.URL %}
|
||||
<tr><td>{% trans "URL" %}</td><td><a href="{{ part.URL }}">{{ part.URL }}</a></td></tr>
|
||||
{% if part.link %}
|
||||
<tr><td>{% trans "External Link" %}</td><td><a href="{{ part.link }}">{{ part.link }}</a></td></tr>
|
||||
{% endif %}
|
||||
{% if part.description %}
|
||||
<tr><td>{% trans "Description" %}</td><td>{{ part.description }}</td></tr>
|
||||
|
@ -78,7 +78,7 @@ class POList(generics.ListCreateAPIView):
|
||||
'supplier__image',
|
||||
'reference',
|
||||
'description',
|
||||
'URL',
|
||||
'link',
|
||||
'status',
|
||||
'notes',
|
||||
'creation_date',
|
||||
|
@ -70,7 +70,7 @@ class EditPurchaseOrderForm(HelperForm):
|
||||
'reference',
|
||||
'supplier',
|
||||
'description',
|
||||
'URL',
|
||||
'link',
|
||||
]
|
||||
|
||||
|
||||
|
18
InvenTree/order/migrations/0018_auto_20200406_0151.py
Normal file
18
InvenTree/order/migrations/0018_auto_20200406_0151.py
Normal file
@ -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',
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
||||
|
@ -21,7 +21,7 @@ class POSerializer(InvenTreeModelSerializer):
|
||||
'supplier',
|
||||
'reference',
|
||||
'description',
|
||||
'URL',
|
||||
'link',
|
||||
'status',
|
||||
'notes',
|
||||
]
|
||||
|
@ -25,9 +25,6 @@ InvenTree | {{ order }}
|
||||
<div class='media-body'>
|
||||
<h4>{{ order }}</h4>
|
||||
<p>{{ order.description }}</p>
|
||||
{% if order.URL %}
|
||||
<a href="{{ order.URL }}">{{ order.URL }}</a>
|
||||
{% endif %}
|
||||
<p>
|
||||
<div class='btn-row'>
|
||||
<div class='btn-group'>
|
||||
@ -64,25 +61,37 @@ InvenTree | {{ order }}
|
||||
<h4>{% trans "Purchase Order Details" %}</h4>
|
||||
<table class='table'>
|
||||
<tr>
|
||||
<td><span class='fas fa-industry'></span></td>
|
||||
<td>{% trans "Supplier" %}</td>
|
||||
<td><a href="{% url 'company-detail' order.supplier.id %}">{{ order.supplier }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{% include "order/order_status.html" %}</td>
|
||||
</tr>
|
||||
{% if order.link %}
|
||||
<tr>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>External Link</td>
|
||||
<td><a href="{{ order.link }}">{{ order.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Created" %}</td>
|
||||
<td>{{ order.creation_date }}<span class='badge'>{{ order.created_by }}</span></td>
|
||||
</tr>
|
||||
{% if order.issue_date %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Issued" %}</td>
|
||||
<td>{{ order.issue_date }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if order.status == OrderStatus.COMPLETE %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Received" %}</td>
|
||||
<td>{{ order.complete_date }}<span class='badge'>{{ order.received_by }}</span></td>
|
||||
</tr>
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -120,7 +120,7 @@ class EditPartForm(HelperForm):
|
||||
'keywords',
|
||||
'variant_of',
|
||||
'is_template',
|
||||
'URL',
|
||||
'link',
|
||||
'default_location',
|
||||
'default_supplier',
|
||||
'units',
|
||||
|
@ -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):
|
||||
|
||||
|
18
InvenTree/part/migrations/0035_auto_20200406_0045.py
Normal file
18
InvenTree/part/migrations/0035_auto_20200406_0045.py
Normal file
@ -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',
|
||||
),
|
||||
]
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -60,11 +60,11 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if part.URL %}
|
||||
{% if part.link %}
|
||||
<tr>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td><b>{% trans "Link" %}</b></td>
|
||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
||||
<td><b>{% trans "External Link" %}</b></td>
|
||||
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if part.default_location %}
|
||||
|
@ -72,14 +72,16 @@
|
||||
<table class='table table-condensed'>
|
||||
{% if part.IPN %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "IPN" %}</td>
|
||||
<td>{{ part.IPN }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if part.URL %}
|
||||
{% if part.link %}
|
||||
<tr>
|
||||
<td>{% trans "URL" %}</td>
|
||||
<td><a href="{{ part.URL }}">{{ part.URL }}</a></td>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
]
|
||||
|
19
InvenTree/stock/migrations/0024_auto_20200405_2239.py
Normal file
19
InvenTree/stock/migrations/0024_auto_20200405_2239.py
Normal file
@ -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),
|
||||
),
|
||||
]
|
23
InvenTree/stock/migrations/0025_auto_20200405_2243.py
Normal file
23
InvenTree/stock/migrations/0025_auto_20200405_2243.py
Normal file
@ -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',
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
||||
|
@ -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',
|
||||
|
@ -74,6 +74,7 @@
|
||||
<div class='col-sm-6'>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>Part</td>
|
||||
<td>
|
||||
{% include "hover_image.html" with image=item.part.image hover=True %}
|
||||
@ -82,71 +83,84 @@
|
||||
</tr>
|
||||
{% if item.belongs_to %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Belongs To" %}</td>
|
||||
<td><a href="{% url 'stock-item-detail' item.belongs_to.id %}">{{ item.belongs_to }}</a></td>
|
||||
</tr>
|
||||
{% elif item.location %}
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Location" %}</td>
|
||||
<td><a href="{% url 'stock-location-detail' item.location.id %}">{{ item.location.name }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.serialized %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Serial Number" %}</td>
|
||||
<td>{{ item.serial }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Quantity" %}</td>
|
||||
<td>{% decimal item.quantity %} {% if item.part.units %}{{ item.part.units }}{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.batch %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Batch" %}</td>
|
||||
<td>{{ item.batch }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.build %}
|
||||
<tr>
|
||||
<td><span class='fas fa-tools'></span></td>
|
||||
<td>{% trans "Build" %}</td>
|
||||
<td><a href="{% url 'build-detail' item.build.id %}">{{ item.build }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.purchase_order %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Purchase Order" %}</td>
|
||||
<td><a href="{% url 'po-detail' item.purchase_order.id %}">{{ item.purchase_order }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.customer %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Customer" %}</td>
|
||||
<td>{{ item.customer.name }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.URL %}
|
||||
{% if item.link %}
|
||||
<tr>
|
||||
<td>{% trans "URL" %}</td>
|
||||
<td><a href="{{ item.URL }}">{{ item.URL }}</a></td>
|
||||
<td><span class='fas fa-link'></span>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ item.link }}">{{ item.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if item.supplier_part %}
|
||||
<tr>
|
||||
<td><span class='fas fa-industry'></span></td>
|
||||
<td>{% trans "Supplier" %}</td>
|
||||
<td><a href="{% url 'company-detail' item.supplier_part.supplier.id %}">{{ item.supplier_part.supplier.name }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>{% trans "Supplier Part" %}</td>
|
||||
<td><a href="{% url 'supplier-part-detail' item.supplier_part.id %}">{{ item.supplier_part.SKU }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Last Updated" %}</td>
|
||||
<td>{{ item.updated }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Last Stocktake" %}</td>
|
||||
{% if item.stocktake_date %}
|
||||
<td>{{ item.stocktake_date }} <span class='badge'>{{ item.stocktake_user }}</span></td>
|
||||
@ -155,6 +169,7 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{{ item.get_status_display }}</td>
|
||||
</tr>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user