mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Admin for part tracking
- Added 'has_tracking_info' function for StockItem
This commit is contained in:
parent
76ee150ca4
commit
09b357976d
@ -2,7 +2,7 @@ from django.contrib import admin
|
||||
from simple_history.admin import SimpleHistoryAdmin
|
||||
|
||||
from .models import StockLocation, StockItem
|
||||
|
||||
from .models import StockItemTracking
|
||||
|
||||
class LocationAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'pathstring', 'description')
|
||||
@ -12,5 +12,9 @@ class StockItemAdmin(SimpleHistoryAdmin):
|
||||
list_display = ('part', 'quantity', 'location', 'status', 'updated')
|
||||
|
||||
|
||||
class StockTrackingAdmin(admin.ModelAdmin):
|
||||
list_display = ('item', 'date', 'title')
|
||||
|
||||
admin.site.register(StockLocation, LocationAdmin)
|
||||
admin.site.register(StockItem, StockItemAdmin)
|
||||
admin.site.register(StockItemTracking, StockTrackingAdmin)
|
@ -121,6 +121,10 @@ class StockItem(models.Model):
|
||||
|
||||
infinite = models.BooleanField(default=False)
|
||||
|
||||
@property
|
||||
def has_tracking_info(self):
|
||||
return self.tracking_info.all().count() > 0
|
||||
|
||||
@transaction.atomic
|
||||
def stocktake(self, count, user):
|
||||
""" Perform item stocktake.
|
||||
|
@ -72,6 +72,21 @@
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
{% if item.has_tracking_info %}
|
||||
<h3>Stock Tracking</h3>
|
||||
<ul class='list-group'>
|
||||
{% for track in item.tracking_info.all %}
|
||||
<li class='list-group-item'>
|
||||
<b>{{ track.title }}</b>
|
||||
{% if track.description %}
|
||||
<br><br>{{ track.description }}</i>
|
||||
{% endif %}
|
||||
<span class='badge'>{{ track.date }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<div class='container-fluid'>
|
||||
<a href="{% url 'stock-item-edit' item.id %}">
|
||||
<button class='btn btn-info'>Edit Stock Item</button>
|
||||
|
Loading…
Reference in New Issue
Block a user