mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
commit
89ea69ff25
@ -241,4 +241,8 @@ class SearchView(TemplateView):
|
||||
|
||||
context = self.get_context_data()
|
||||
|
||||
query = request.POST.get('search', '')
|
||||
|
||||
context['query'] = query
|
||||
|
||||
return super(TemplateView, self).render_to_response(context)
|
||||
|
@ -121,7 +121,7 @@ class PartList(generics.ListCreateAPIView):
|
||||
ordering = 'name'
|
||||
|
||||
search_fields = [
|
||||
'name',
|
||||
'$name',
|
||||
'description',
|
||||
]
|
||||
|
||||
|
@ -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' %}"
|
||||
});
|
||||
|
18
InvenTree/stock/migrations/0007_auto_20190417_1812.py
Normal file
18
InvenTree/stock/migrations/0007_auto_20190417_1812.py
Normal 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),
|
||||
),
|
||||
]
|
20
InvenTree/stock/migrations/0008_auto_20190417_1819.py
Normal file
20
InvenTree/stock/migrations/0008_auto_20190417_1819.py
Normal 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),
|
||||
),
|
||||
]
|
@ -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)
|
||||
|
@ -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">
|
||||
|
@ -2,14 +2,60 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3>InvenTree Search</h3>
|
||||
<h3>Search Results</h3>
|
||||
|
||||
<p>
|
||||
Search stuff goes here.
|
||||
</p>
|
||||
<div>
|
||||
{% include "search_form.html" with query_text=query %}
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<h3>Parts <span id='part-result-count'></span></h3>
|
||||
<table class='table table-striped table-condensed' data-toolbar="#button-toolbar" id='part-results-table'>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$("#part-results-table").on('load-success.bs.table', function() {
|
||||
var n = $("#part-results-table").bootstrapTable('getData').length;
|
||||
$("#part-result-count").html("(found " + n + " results)");
|
||||
});
|
||||
|
||||
$("#part-results-table").bootstrapTable({
|
||||
sortable: true,
|
||||
search: true,
|
||||
pagination: true,
|
||||
queryParams: function(p) {
|
||||
return {
|
||||
search: "{{ query }}",
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'pk',
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: 'Name',
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, row.url);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'description',
|
||||
title: 'Description',
|
||||
searchable: true,
|
||||
}
|
||||
],
|
||||
url: "{% url 'api-part-list' %}"
|
||||
});
|
||||
|
||||
|
||||
|
||||
{% block js_load %}
|
||||
{% endblock %}
|
@ -12,13 +12,7 @@
|
||||
<li><a href="{% url 'company-index' %}">Companies</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<input type="text" name='search' class="form-control" placeholder="Search">
|
||||
</div>
|
||||
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
{% include "search_form.html" %}
|
||||
{% if user.is_authenticated %}
|
||||
<li class='dropdown'>
|
||||
<a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span> <b>{{ user.get_username }}</b></a>
|
||||
|
7
InvenTree/templates/search_form.html
Normal file
7
InvenTree/templates/search_form.html
Normal file
@ -0,0 +1,7 @@
|
||||
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<input type="text" name='search' class="form-control" placeholder="Search"{% if query_text %} value="{{ query }}"{% endif %}>
|
||||
</div>
|
||||
<button type="submit" id='search-submit' class="btn btn-default">Submit</button>
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user