mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
4a02a90954
@ -71,6 +71,11 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
kwargs['supplier_detail'] = str2bool(self.request.GET.get('supplier_detail', False))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
kwargs['context'] = self.get_serializer_context()
|
kwargs['context'] = self.get_serializer_context()
|
||||||
|
|
||||||
return self.serializer_class(*args, **kwargs)
|
return self.serializer_class(*args, **kwargs)
|
||||||
|
@ -410,9 +410,13 @@ class StockItem(MPTTModel):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tracking_info_count(self):
|
||||||
|
return self.tracking_info.count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_tracking_info(self):
|
def has_tracking_info(self):
|
||||||
return self.tracking_info.count() > 0
|
return self.tracking_info_count > 0
|
||||||
|
|
||||||
def addTransactionNote(self, title, user, notes='', url='', system=True):
|
def addTransactionNote(self, title, user, notes='', url='', system=True):
|
||||||
""" Generation a stock transaction note for this item.
|
""" Generation a stock transaction note for this item.
|
||||||
|
@ -8,6 +8,7 @@ from .models import StockItem, StockLocation
|
|||||||
from .models import StockItemTracking
|
from .models import StockItemTracking
|
||||||
|
|
||||||
from part.serializers import PartBriefSerializer
|
from part.serializers import PartBriefSerializer
|
||||||
|
from company.serializers import SupplierPartSerializer
|
||||||
from InvenTree.serializers import UserSerializerBrief, InvenTreeModelSerializer
|
from InvenTree.serializers import UserSerializerBrief, InvenTreeModelSerializer
|
||||||
|
|
||||||
|
|
||||||
@ -61,13 +62,17 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
|
|
||||||
part_image = serializers.CharField(source='part__image', read_only=True)
|
part_image = serializers.CharField(source='part__image', read_only=True)
|
||||||
|
|
||||||
|
tracking_items = serializers.IntegerField(source='tracking_info_count', read_only=True)
|
||||||
|
|
||||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||||
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
|
location_detail = LocationBriefSerializer(source='location', many=False, read_only=True)
|
||||||
|
supplier_detail = SupplierPartSerializer(source='supplier_part', many=False, read_only=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
part_detail = kwargs.pop('part_detail', False)
|
part_detail = kwargs.pop('part_detail', False)
|
||||||
location_detail = kwargs.pop('location_detail', False)
|
location_detail = kwargs.pop('location_detail', False)
|
||||||
|
supplier_detail = kwargs.pop('supplier_detail', False)
|
||||||
|
|
||||||
super(StockItemSerializer, self).__init__(*args, **kwargs)
|
super(StockItemSerializer, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
@ -77,6 +82,9 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
if location_detail is not True:
|
if location_detail is not True:
|
||||||
self.fields.pop('location_detail')
|
self.fields.pop('location_detail')
|
||||||
|
|
||||||
|
if supplier_detail is not True:
|
||||||
|
self.fields.pop('supplier_detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
fields = [
|
fields = [
|
||||||
@ -94,8 +102,10 @@ class StockItemSerializer(InvenTreeModelSerializer):
|
|||||||
'quantity',
|
'quantity',
|
||||||
'serial',
|
'serial',
|
||||||
'supplier_part',
|
'supplier_part',
|
||||||
|
'supplier_detail',
|
||||||
'status',
|
'status',
|
||||||
'status_text',
|
'status_text',
|
||||||
|
'tracking_items',
|
||||||
'url',
|
'url',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<div class='modal-form-content'>
|
<div class='modal-form-content'>
|
||||||
<div>
|
<div>
|
||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
|
<col width='25'>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>{% trans "Instance Name" %}</td>
|
<td>{% trans "Instance Name" %}</td>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
|
<col width='25'>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='2'><b>{% trans "Parts" %}</b></td>
|
<td colspan='2'><b>{% trans "Parts" %}</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user