Update model for StockItem

This commit is contained in:
Oliver Walters 2019-04-17 18:34:21 +10:00
parent 69e8f4f5cc
commit b9b8b5ee12
5 changed files with 136 additions and 82 deletions

View File

@ -78,9 +78,15 @@
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
return renderLink(value, row.url);
var text = renderLink(value, row.url)
text = text + "<span class='badge'>" + row.status + "</span>";
return text;
}
}
},
{
field: 'notes',
title: 'Notes',
},
],
url: "{% url 'api-stock-list' %}"
});

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-04-17 08:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('stock', '0006_stockitem_uuid'),
]
operations = [
migrations.AlterField(
model_name='stockitem',
name='notes',
field=models.CharField(blank=True, help_text='Stock Item Notes', max_length=250),
),
]

View File

@ -0,0 +1,20 @@
# Generated by Django 2.2 on 2019-04-17 08:19
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('stock', '0007_auto_20190417_1812'),
]
operations = [
migrations.AlterField(
model_name='stockitem',
name='stocktake_user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stocktake_stock', to=settings.AUTH_USER_MODEL),
),
]

View File

@ -163,7 +163,8 @@ class StockItem(models.Model):
# last time the stock was checked / counted
stocktake_date = models.DateField(blank=True, null=True)
stocktake_user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
stocktake_user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True,
related_name='stocktake_stock')
review_needed = models.BooleanField(default=False)
@ -184,7 +185,7 @@ class StockItem(models.Model):
choices=ITEM_STATUS_CODES.items(),
validators=[MinValueValidator(0)])
notes = models.TextField(blank=True)
notes = models.CharField(max_length=250, blank=True, help_text='Stock Item Notes')
# If stock item is incoming, an (optional) ETA field
# expected_arrival = models.DateField(null=True, blank=True)

View File

@ -20,7 +20,7 @@
<li><a href="#" id='stock-edit' title='Edit stock item'>Edit stock item</a></li>
<li><a href="#" id='stock-move' title='Move stock item'>Move stock item</a></li>
<li><a href='#' id='stock-add' title='Add stock'>Add to stock</a></li>
<li><a href='#' id='stock-remove' title='Remove stock'>Remove from stock</a></li>
<li><a href='#' id='stock-remove' title='Remove stock'>Take from stock</a></li>
<li><a href='#' id='stock-stocktake' title='Count stock'>Stocktake</a></li>
{% endif %}
<li><a href="#" id='stock-delete' title='Delete stock item'>Delete stock item</a></li>
@ -31,86 +31,95 @@
</div>
</div>
{% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %}
<div class='row'>
<div class='col-sm-6'>
<table class="table table-striped">
<tr>
<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>
<td><a href="{% url 'stock-item-detail' item.belongs_to.id %}">{{ item.belongs_to }}</a></td>
</tr>
{% elif item.location %}
<tr>
<td>Location</td>
<td><a href="{% url 'stock-location-detail' item.location.id %}">{{ item.location.name }}</a></td>
</tr>
{% endif %}
{% if item.serial %}
<tr>
<td>Serial</td>
<td>{{ item.serial }}</td>
</tr>
{% else %}
<tr>
<td>Quantity</td>
<td>{{ item.quantity }}</td>
</tr>
{% endif %}
{% if item.batch %}
<tr>
<td>Batch</td>
<td>{{ item.batch }}</td>
</tr>
{% endif %}
{% if item.customer %}
<tr>
<td>Customer</td>
<td>{{ item.customer.name }}</td>
</tr>
{% endif %}
{% if item.URL %}
<tr>
<td>URL</td>
<td><a href="{{ item.URL }}">{{ item.URL }}</a></td>
</tr>
{% endif %}
{% if item.supplier_part %}
<tr>
<td>Supplier Part</td>
<td><a href="{% url 'supplier-part-detail' item.supplier_part.id %}">{{ item.supplier_part.SKU }}</a></td>
</tr>
{% endif %}
<tr>
<td>Last Updated</td>
<td>{{ item.updated }}</td>
</tr>
<tr>
<td>Last Stocktake</td>
{% if item.stocktake_date %}
<td>{{ item.stocktake_date }} <span class='badge'>{{ item.stocktake_user }}</span></td>
{% else %}
<td>No stocktake performed</td>
{% endif %}
</tr>
<tr>
<td>Status</td>
<td>{{ item.get_status_display }}</td>
</tr>
{% if item.notes %}
<tr>
<td>Notes</td>
<td>{{ item.notes }}</td>
</tr>
{% endif %}
</table>
</div>
<div class='col-sm-6'>
{% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %}
</div>
</div>
<table class="table table-striped">
<tr>
<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>
<td><a href="{% url 'stock-item-detail' item.belongs_to.id %}">{{ item.belongs_to }}</a></td>
</tr>
{% elif item.location %}
<tr>
<td>Location</td>
<td><a href="{% url 'stock-location-detail' item.location.id %}">{{ item.location.name }}</a></td>
</tr>
{% endif %}
{% if item.serial %}
<tr>
<td>Serial</td>
<td>{{ item.serial }}</td>
</tr>
{% else %}
<tr>
<td>Quantity</td>
<td>{{ item.quantity }}</td>
</tr>
{% endif %}
{% if item.batch %}
<tr>
<td>Batch</td>
<td>{{ item.batch }}</td>
</tr>
{% endif %}
{% if item.customer %}
<tr>
<td>Customer</td>
<td>{{ item.customer.name }}</td>
</tr>
{% endif %}
{% if item.URL %}
<tr>
<td>URL</td>
<td><a href="{{ item.URL }}">{{ item.URL }}</a></td>
</tr>
{% endif %}
{% if item.supplier_part %}
<tr>
<td>Supplier Part</td>
<td><a href="{% url 'supplier-part-detail' item.supplier_part.id %}">{{ item.supplier_part.SKU }}</a></td>
</tr>
{% endif %}
<tr>
<td>Updated</td>
<td>{{ item.updated }}</td>
</tr>
{% if item.stocktake_date %}
<tr>
<td>Stocktake</td>
<td>{{ item.stocktake_date }} <span class='badge'>{{ item.stocktake_user }}</span></td>
</tr>
{% endif %}
<tr>
<td>Status</td>
<td>{{ item.get_status_display }}</td>
</tr>
{% if item.notes %}
<tr>
<td>Notes</td>
<td>{{ item.notes }}</td>
</tr>
{% endif %}
</table>
{% if item.has_tracking_info %}
<hr>
<div class="panel-group">
<div class="panel panel-default">