diff --git a/InvenTree/company/serializers.py b/InvenTree/company/serializers.py
index 88792f7f64..2967dbebd5 100644
--- a/InvenTree/company/serializers.py
+++ b/InvenTree/company/serializers.py
@@ -25,7 +25,25 @@ class CompanySerializer(serializers.ModelSerializer):
""" Serializer for Company object (full detail) """
url = serializers.CharField(source='get_absolute_url', read_only=True)
+ part_count = serializers.CharField(read_only=True)
class Meta:
model = Company
- fields = '__all__'
+ fields = [
+ 'id',
+ 'url',
+ 'name',
+ 'description',
+ 'website',
+ 'name',
+ 'phone',
+ 'address',
+ 'email',
+ 'contact',
+ 'URL',
+ 'image',
+ 'notes',
+ 'is_customer',
+ 'is_supplier',
+ 'part_count'
+ ]
diff --git a/InvenTree/company/templates/company/detail_stock.html b/InvenTree/company/templates/company/detail_stock.html
index 89ea0fdb2f..5bc7b9598a 100644
--- a/InvenTree/company/templates/company/detail_stock.html
+++ b/InvenTree/company/templates/company/detail_stock.html
@@ -7,19 +7,20 @@
Supplier Stock
-
+{% include "stock_table.html" %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
- loadStockTable($('#stock-table'),
- {
- url: "{% url 'api-stock-list' %}",
- params: {
- supplier: {{ company.id }},
- }
+ loadStockTable($('#stock-table'), {
+ url: "{% url 'api-stock-list' %}",
+ params: {
+ supplier: {{ company.id }},
+ },
+ buttons: [
+ '#stock-options',
+ ]
});
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html
index d4a8659798..cea452fdc1 100644
--- a/InvenTree/company/templates/company/index.html
+++ b/InvenTree/company/templates/company/index.html
@@ -73,7 +73,14 @@ InvenTree | Supplier List
}
return '';
}
- }
+ },
+ {
+ field: 'part_count',
+ title: 'Parts',
+ formatter: function(value, row, index, field) {
+ return renderLink(value, row.url + 'parts/');
+ }
+ },
],
url: "{% url 'api-company-list' %}"
});
diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html
index 3311dafb8d..8b9561ea2e 100644
--- a/InvenTree/part/templates/part/stock.html
+++ b/InvenTree/part/templates/part/stock.html
@@ -13,25 +13,7 @@
-
-
-
-
+{% include "stock_table.html" %}
{% endblock %}
@@ -62,43 +44,4 @@
url: "{% url 'api-stock-list' %}",
});
- function selectedStock() {
- return $("#stock-table").bootstrapTable('getSelections');
- }
-
- $("#multi-item-move").click(function() {
-
- var items = selectedStock();
-
- moveStockItems(items,
- {
- success: function() {
- $("#stock-table").bootstrapTable('refresh');
- }
- });
-
- return false;
- });
-
- $("#multi-item-stocktake").click(function() {
- updateStockItems({
- action: 'stocktake'
- });
- return false;
- });
-
- $("#multi-item-take").click(function() {
- updateStockItems({
- action: 'remove',
- });
- return false;
- });
-
- $("#multi-item-give").click(function() {
- updateStockItems({
- action: 'add',
- });
- return false;
- })
-
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/static/script/inventree/stock.js b/InvenTree/static/script/inventree/stock.js
index 9f9c5fd40b..d34ed9beee 100644
--- a/InvenTree/static/script/inventree/stock.js
+++ b/InvenTree/static/script/inventree/stock.js
@@ -43,6 +43,7 @@ function updateStock(items, options={}) {
html += 'Item | ';
html += 'Location | ';
html += 'Quantity | ';
+ html += '' + options.action + ' | ';
html += '';
@@ -71,6 +72,9 @@ function updateStock(items, options={}) {
} else {
html += 'No location set | ';
}
+
+ html += '' + item.quantity + ' | ';
+
html += "';
html += " ";
+ html += "Note field must be filled ";
+
+ html += `
+
+
+
+ Confirm stock count
+ `;
- html += "Note field must be filled ";
var title = '';
@@ -109,6 +123,7 @@ function updateStock(items, options={}) {
});
$(modal).find('#note-warning').hide();
+ $(modal).find('#confirm-warning').hide();
modalEnable(modal, true);
@@ -116,13 +131,23 @@ function updateStock(items, options={}) {
var stocktake = [];
var notes = $(modal).find('#stocktake-notes').val();
+ var confirm = $(modal).find('#stocktake-confirm').is(':checked');
+
+ var valid = true;
if (!notes) {
$(modal).find('#note-warning').show();
- return false;
+ valid = false;
}
- var valid = true;
+ if (!confirm) {
+ $(modal).find('#confirm-warning').show();
+ valid = false;
+ }
+
+ if (!valid) {
+ return false;
+ }
// Form stocktake data
for (idx = 0; idx < items.length; idx++) {
@@ -413,6 +438,42 @@ function loadStockTable(table, options) {
if (options.buttons) {
linkButtonsToSelection(table, options.buttons);
}
+
+ // Automatically link button callbacks
+ $('#multi-item-stocktake').click(function() {
+ updateStockItems({
+ action: 'stocktake',
+ });
+ return false;
+ });
+
+ $('#multi-item-remove').click(function() {
+ updateStockItems({
+ action: 'remove',
+ });
+ return false;
+ });
+
+ $('#multi-item-add').click(function() {
+ updateStockItems({
+ action: 'add',
+ });
+ return false;
+ });
+
+ $("#multi-item-move").click(function() {
+
+ var items = $("#stock-table").bootstrapTable('getSelections');
+
+ moveStockItems(items,
+ {
+ success: function() {
+ $("#stock-table").bootstrapTable('refresh');
+ }
+ });
+
+ return false;
+ });
}
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html
index 9ea210a04e..ae36078ece 100644
--- a/InvenTree/stock/templates/stock/location.html
+++ b/InvenTree/stock/templates/stock/location.html
@@ -44,24 +44,7 @@
-
-
-
-
+{% include "stock_table.html" %}
{% include 'modals.html' %}
@@ -149,46 +132,7 @@
return false;
});
-
- function selectedStock() {
- return $("#stock-table").bootstrapTable('getSelections');
- }
-
- $("#multi-item-move").click(function() {
-
- var items = selectedStock();
-
- moveStockItems(items,
- {
- success: function() {
- $("#stock-table").bootstrapTable('refresh');
- }
- });
-
- return false;
- });
-
- $('#multi-item-stocktake').click(function() {
- updateStockItems({
- action: 'stocktake',
- });
- return false;
- });
-
- $('#multi-item-remove').click(function() {
- updateStockItems({
- action: 'remove',
- });
- return false;
- });
-
- $('#multi-item-add').click(function() {
- updateStockItems({
- action: 'add',
- });
- return false;
- });
-
+
loadStockTable($("#stock-table"), {
buttons: [
'#stock-options',
diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html
new file mode 100644
index 0000000000..f5411fabb8
--- /dev/null
+++ b/InvenTree/templates/stock_table.html
@@ -0,0 +1,17 @@
+
+
+
\ No newline at end of file
|