mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Merge pull request #101 from SchrodingersGat/stock-fix
Fixes error in StockItem serializer
This commit is contained in:
commit
20acf1f692
@ -226,7 +226,7 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
'supplier_part',
|
'supplier_part',
|
||||||
'customer',
|
'customer',
|
||||||
'belongs_to',
|
'belongs_to',
|
||||||
'status',
|
#'status',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -304,8 +304,6 @@ location_endpoints = [
|
|||||||
|
|
||||||
|
|
||||||
stock_api_urls = [
|
stock_api_urls = [
|
||||||
# Detail for a single stock item
|
|
||||||
url(r'^(?P<pk>[0-9]+)/', include(stock_endpoints)),
|
|
||||||
|
|
||||||
url(r'location/?', StockLocationList.as_view(), name='api-location-list'),
|
url(r'location/?', StockLocationList.as_view(), name='api-location-list'),
|
||||||
|
|
||||||
@ -319,5 +317,8 @@ stock_api_urls = [
|
|||||||
|
|
||||||
url(r'^tree/?', StockCategoryTree.as_view(), name='api-stock-tree'),
|
url(r'^tree/?', StockCategoryTree.as_view(), name='api-stock-tree'),
|
||||||
|
|
||||||
|
# Detail for a single stock item
|
||||||
|
url(r'^(?P<pk>\d+)/', include(stock_endpoints)),
|
||||||
|
|
||||||
url(r'^.*$', StockList.as_view(), name='api-stock-list'),
|
url(r'^.*$', StockList.as_view(), name='api-stock-list'),
|
||||||
]
|
]
|
@ -27,19 +27,19 @@ class StockLocation(InvenTreeTree):
|
|||||||
return '/stock/location/{id}/'.format(id=self.id)
|
return '/stock/location/{id}/'.format(id=self.id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def items(self):
|
def stock_items(self):
|
||||||
return self.stockitem_set.all()
|
return self.stockitem_set.all()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_items(self):
|
def has_items(self):
|
||||||
return self.items.count() > 0
|
return self.stock_items.count() > 0
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
|
@receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log')
|
||||||
def before_delete_stock_location(sender, instance, using, **kwargs):
|
def before_delete_stock_location(sender, instance, using, **kwargs):
|
||||||
|
|
||||||
# Update each part in the stock location
|
# Update each part in the stock location
|
||||||
for item in instance.items.all():
|
for item in instance.stock_items.all():
|
||||||
item.location = instance.parent
|
item.location = instance.parent
|
||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ the top level 'Stock' location.
|
|||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if location.items.all|length > 0 %}
|
{% if location.stock_items.all|length > 0 %}
|
||||||
<p>This location contains {{ location.items.all|length }} stock items.<br>
|
<p>This location contains {{ location.stock_items.all|length }} stock items.<br>
|
||||||
{% if location.parent %}
|
{% if location.parent %}
|
||||||
If this location is deleted, these items will be moved to the '{{ location.parent.name }}' location.
|
If this location is deleted, these items will be moved to the '{{ location.parent.name }}' location.
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -29,7 +29,7 @@ If this location is deleted, these items will be moved to the top level 'Stock'
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul class='list-group'>
|
<ul class='list-group'>
|
||||||
{% for item in location.items.all %}
|
{% for item in location.stock_items.all %}
|
||||||
<li class='list-group-item'><b>{{ item.part.name }}</b> - <i>{{ item.part.description }}</i><span class='badge'>{{ item.quantity }}</span></li>
|
<li class='list-group-item'><b>{{ item.part.name }}</b> - <i>{{ item.part.description }}</i><span class='badge'>{{ item.quantity }}</span></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user