diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 6fc4302bfa..c160398caf 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -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) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index d849506c06..e13d493fc3 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -121,7 +121,7 @@ class PartList(generics.ListCreateAPIView): ordering = 'name' search_fields = [ - 'name', + '$name', 'description', ] diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index 96fd03e3cd..5bece01f2e 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -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 + "" + row.status + ""; + return text; } - } + }, + { + field: 'notes', + title: 'Notes', + }, ], url: "{% url 'api-stock-list' %}" }); diff --git a/InvenTree/stock/migrations/0007_auto_20190417_1812.py b/InvenTree/stock/migrations/0007_auto_20190417_1812.py new file mode 100644 index 0000000000..8b9ec638e3 --- /dev/null +++ b/InvenTree/stock/migrations/0007_auto_20190417_1812.py @@ -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), + ), + ] diff --git a/InvenTree/stock/migrations/0008_auto_20190417_1819.py b/InvenTree/stock/migrations/0008_auto_20190417_1819.py new file mode 100644 index 0000000000..46659abd66 --- /dev/null +++ b/InvenTree/stock/migrations/0008_auto_20190417_1819.py @@ -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), + ), + ] diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 7731324622..6af5b3d4b7 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -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) diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 572f7b8e4b..f1f0a5db1d 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -20,7 +20,7 @@
  • Edit stock item
  • Move stock item
  • Add to stock
  • -
  • Remove from stock
  • +
  • Take from stock
  • Stocktake
  • {% endif %}
  • Delete stock item
  • @@ -31,86 +31,95 @@ -{% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %} +
    +
    + + + + + + + + + + {% if item.belongs_to %} + + + + + {% elif item.location %} + + + + + {% endif %} + {% if item.serial %} + + + + + {% else %} + + + + + {% endif %} + {% if item.batch %} + + + + + {% endif %} + {% if item.customer %} + + + + + {% endif %} + {% if item.URL %} + + + + + {% endif %} + {% if item.supplier_part %} + + + + + {% endif %} + + + + + + + {% if item.stocktake_date %} + + {% else %} + + {% endif %} + + + + + + {% if item.notes %} + + + + + {% endif %} +
    Part{{ item.part.name }}
    UUID{{ item.uuid }}
    Belongs To{{ item.belongs_to }}
    Location{{ item.location.name }}
    Serial{{ item.serial }}
    Quantity{{ item.quantity }}
    Batch{{ item.batch }}
    Customer{{ item.customer.name }}
    URL{{ item.URL }}
    Supplier Part{{ item.supplier_part.SKU }}
    Last Updated{{ item.updated }}
    Last Stocktake{{ item.stocktake_date }} {{ item.stocktake_user }}No stocktake performed
    Status{{ item.get_status_display }}
    Notes{{ item.notes }}
    +
    +
    + {% qr_from_text item.uuid size="s" image_format="png" error_correction="L" %} +
    +
    - - - - - - - - - -{% if item.belongs_to %} - - - - -{% elif item.location %} - - - - -{% endif %} -{% if item.serial %} - - - - -{% else %} - - - - -{% endif %} -{% if item.batch %} - - - - -{% endif %} -{% if item.customer %} - - - - -{% endif %} -{% if item.URL %} - - - - -{% endif %} -{% if item.supplier_part %} - - - - -{% endif %} - - - - -{% if item.stocktake_date %} - - - - -{% endif %} - - - - -{% if item.notes %} - - - - -{% endif %} -
    Part{{ item.part.name }}
    UUID{{ item.uuid }}
    Belongs To{{ item.belongs_to }}
    Location{{ item.location.name }}
    Serial{{ item.serial }}
    Quantity{{ item.quantity }}
    Batch{{ item.batch }}
    Customer{{ item.customer.name }}
    URL{{ item.URL }}
    Supplier Part{{ item.supplier_part.SKU }}
    Updated{{ item.updated }}
    Stocktake{{ item.stocktake_date }} {{ item.stocktake_user }}
    Status{{ item.get_status_display }}
    Notes{{ item.notes }}
    {% if item.has_tracking_info %} +
    diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 2e8c755d3c..58736b811a 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -2,14 +2,60 @@ {% block content %} -

    InvenTree Search

    +

    Search Results

    -

    - Search stuff goes here. -

    +
    +{% include "search_form.html" with query_text=query %} +
    + +

    +

    Parts

    + +
    {% 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 %} \ No newline at end of file diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 31e0d4de9b..64bb7ec34c 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -12,13 +12,7 @@
  • Companies