mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 19:15:41 +00:00
@ -272,7 +272,6 @@ class StockList(generics.ListCreateAPIView):
|
||||
|
||||
filter_fields = [
|
||||
'part',
|
||||
'uuid',
|
||||
'supplier_part',
|
||||
'customer',
|
||||
'belongs_to',
|
||||
@ -346,11 +345,11 @@ class LocationDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
|
||||
stock_endpoints = [
|
||||
url(r'^$', StockDetail.as_view(), name='stockitem-detail'),
|
||||
url(r'^$', StockDetail.as_view(), name='api-stock-detail'),
|
||||
]
|
||||
|
||||
location_endpoints = [
|
||||
url(r'^$', LocationDetail.as_view(), name='stocklocation-detail'),
|
||||
url(r'^$', LocationDetail.as_view(), name='api-location-detail'),
|
||||
]
|
||||
|
||||
stock_api_urls = [
|
||||
|
17
InvenTree/stock/migrations/0013_remove_stockitem_uuid.py
Normal file
17
InvenTree/stock/migrations/0013_remove_stockitem_uuid.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 2.2 on 2019-05-02 10:39
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0012_auto_20190502_0058'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='stockitem',
|
||||
name='uuid',
|
||||
),
|
||||
]
|
@ -17,7 +17,7 @@ from django.db.models.signals import pre_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
from InvenTree import helpers
|
||||
|
||||
from InvenTree.models import InvenTreeTree
|
||||
|
||||
@ -36,6 +36,19 @@ class StockLocation(InvenTreeTree):
|
||||
def has_items(self):
|
||||
return self.stock_items.count() > 0
|
||||
|
||||
@property
|
||||
def format_barcode(self):
|
||||
""" Return a JSON string for formatting a barcode for this StockLocation object """
|
||||
|
||||
return helpers.MakeBarcode(
|
||||
'StockLocation',
|
||||
self.id,
|
||||
reverse('api-location-detail', kwargs={'pk': self.id}),
|
||||
{
|
||||
'name': self.name,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
|
||||
def before_delete_stock_location(sender, instance, using, **kwargs):
|
||||
@ -126,8 +139,27 @@ class StockItem(models.Model):
|
||||
('part', 'serial'),
|
||||
]
|
||||
|
||||
# UUID for generating QR codes
|
||||
uuid = models.UUIDField(default=uuid.uuid4, blank=True, editable=False, help_text='Unique ID for the StockItem')
|
||||
@property
|
||||
def format_barcode(self):
|
||||
""" Return a JSON string for formatting a barcode for this StockItem.
|
||||
Can be used to perform lookup of a stockitem using barcode
|
||||
|
||||
Contains the following data:
|
||||
|
||||
{ type: 'StockItem', stock_id: <pk>, part_id: <part_pk> }
|
||||
|
||||
Voltagile data (e.g. stock quantity) should be looked up using the InvenTree API (as it may change)
|
||||
"""
|
||||
|
||||
return helpers.MakeBarcode(
|
||||
'StockItem',
|
||||
self.id,
|
||||
reverse('api-stock-detail', kwargs={'pk': self.id}),
|
||||
{
|
||||
'part_id': self.part.id,
|
||||
'part_name': self.part.name
|
||||
}
|
||||
)
|
||||
|
||||
# The 'master' copy of the part of which this stock item is an instance
|
||||
part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='locations', help_text='Base part')
|
||||
|
@ -38,7 +38,6 @@ class StockItemSerializerBrief(serializers.ModelSerializer):
|
||||
model = StockItem
|
||||
fields = [
|
||||
'pk',
|
||||
'uuid',
|
||||
'part',
|
||||
'part_name',
|
||||
'supplier_part',
|
||||
@ -65,7 +64,6 @@ class StockItemSerializer(serializers.ModelSerializer):
|
||||
model = StockItem
|
||||
fields = [
|
||||
'pk',
|
||||
'uuid',
|
||||
'url',
|
||||
'part',
|
||||
'supplier_part',
|
||||
|
@ -39,10 +39,6 @@
|
||||
<td>Part</td>
|
||||
<td><a href="{% url 'part-stock' item.part.id %}">{{ item.part.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>UUID</td>
|
||||
<td>{{ item.uuid }}</td>
|
||||
</tr>
|
||||
{% if item.belongs_to %}
|
||||
<tr>
|
||||
<td>Belongs To</td>
|
||||
@ -114,7 +110,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class='col-sm-6'>
|
||||
{% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %}
|
||||
{% qr_from_text item.format_barcode size="s" image_format="png" error_correction="L" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "stock/stock_app_base.html" %}
|
||||
{% load static %}
|
||||
{% load qr_code %}
|
||||
{% block content %}
|
||||
|
||||
<div class='row'>
|
||||
@ -25,6 +26,7 @@
|
||||
<li><a href="#" id='location-delete' title='Delete stock location'>Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% qr_from_text location.format_barcode size="s" image_format="png" error_correction="L" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</h3>
|
||||
|
Reference in New Issue
Block a user