mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Merge pull request #345 from SchrodingersGat/stocktake-confirmation
Stocktake confirmation
This commit is contained in:
commit
183871f3cc
@ -25,7 +25,25 @@ class CompanySerializer(serializers.ModelSerializer):
|
|||||||
""" Serializer for Company object (full detail) """
|
""" Serializer for Company object (full detail) """
|
||||||
|
|
||||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||||
|
part_count = serializers.CharField(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Company
|
model = Company
|
||||||
fields = '__all__'
|
fields = [
|
||||||
|
'id',
|
||||||
|
'url',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'website',
|
||||||
|
'name',
|
||||||
|
'phone',
|
||||||
|
'address',
|
||||||
|
'email',
|
||||||
|
'contact',
|
||||||
|
'URL',
|
||||||
|
'image',
|
||||||
|
'notes',
|
||||||
|
'is_customer',
|
||||||
|
'is_supplier',
|
||||||
|
'part_count'
|
||||||
|
]
|
||||||
|
@ -7,19 +7,20 @@
|
|||||||
|
|
||||||
<h3>Supplier Stock</h3>
|
<h3>Supplier Stock</h3>
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' id='stock-table'>
|
{% include "stock_table.html" %}
|
||||||
</table>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
loadStockTable($('#stock-table'),
|
loadStockTable($('#stock-table'), {
|
||||||
{
|
url: "{% url 'api-stock-list' %}",
|
||||||
url: "{% url 'api-stock-list' %}",
|
params: {
|
||||||
params: {
|
supplier: {{ company.id }},
|
||||||
supplier: {{ company.id }},
|
},
|
||||||
}
|
buttons: [
|
||||||
|
'#stock-options',
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -73,7 +73,14 @@ InvenTree | Supplier List
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
field: 'part_count',
|
||||||
|
title: 'Parts',
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return renderLink(value, row.url + 'parts/');
|
||||||
|
}
|
||||||
|
},
|
||||||
],
|
],
|
||||||
url: "{% url 'api-company-list' %}"
|
url: "{% url 'api-company-list' %}"
|
||||||
});
|
});
|
||||||
|
@ -13,25 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div id='button-toolbar'>
|
{% include "stock_table.html" %}
|
||||||
{% if part.active %}
|
|
||||||
<button class='btn btn-success' id='add-stock-item'>New Stock Item</button>
|
|
||||||
{% endif %}
|
|
||||||
<div id='opt-dropdown' class="dropdown" style='float: right;'>
|
|
||||||
<button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options
|
|
||||||
<span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a href='#' id='multi-item-take' title='Take items from stock'>Take items</a></li>
|
|
||||||
<li><a href='#' id='multi-item-give' title='Give items to stock'>Add items</a></li>
|
|
||||||
<li><a href="#" id='multi-item-stocktake' title='Stocktake selected stock items'>Stocktake</a></li>
|
|
||||||
<li><a href='#' id='multi-item-move' title='Move selected stock items'>Move items</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='stock-table'>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@ -62,43 +44,4 @@
|
|||||||
url: "{% url 'api-stock-list' %}",
|
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 %}
|
{% endblock %}
|
@ -43,6 +43,7 @@ function updateStock(items, options={}) {
|
|||||||
html += '<th>Item</th>';
|
html += '<th>Item</th>';
|
||||||
html += '<th>Location</th>';
|
html += '<th>Location</th>';
|
||||||
html += '<th>Quantity</th>';
|
html += '<th>Quantity</th>';
|
||||||
|
html += '<th>' + options.action + '</th>';
|
||||||
|
|
||||||
html += '</thead><tbody>';
|
html += '</thead><tbody>';
|
||||||
|
|
||||||
@ -71,6 +72,9 @@ function updateStock(items, options={}) {
|
|||||||
} else {
|
} else {
|
||||||
html += '<td><i>No location set</i></td>';
|
html += '<td><i>No location set</i></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html += '<td>' + item.quantity + '</td>';
|
||||||
|
|
||||||
html += "<td><input class='form-control' ";
|
html += "<td><input class='form-control' ";
|
||||||
html += "value='" + vCur + "' ";
|
html += "value='" + vCur + "' ";
|
||||||
html += "min='" + vMin + "' ";
|
html += "min='" + vMin + "' ";
|
||||||
@ -87,8 +91,18 @@ function updateStock(items, options={}) {
|
|||||||
html += '</tbody></table>';
|
html += '</tbody></table>';
|
||||||
|
|
||||||
html += "<hr><input type='text' id='stocktake-notes' placeholder='Notes'/>";
|
html += "<hr><input type='text' id='stocktake-notes' placeholder='Notes'/>";
|
||||||
|
html += "<p class='help-inline' id='note-warning'><strong>Note field must be filled</strong></p>";
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<hr>
|
||||||
|
<div class='control-group'>
|
||||||
|
<label class='checkbox'>
|
||||||
|
<input type='checkbox' id='stocktake-confirm' placeholder='Confirm'/>
|
||||||
|
Confirm Stocktake
|
||||||
|
</label>
|
||||||
|
<p class='help-inline' id='confirm-warning'><strong>Confirm stock count</strong></p>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
html += "<p class='warning-msg' id='note-warning'><i>Note field must be filled</i></p>";
|
|
||||||
|
|
||||||
var title = '';
|
var title = '';
|
||||||
|
|
||||||
@ -109,6 +123,7 @@ function updateStock(items, options={}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(modal).find('#note-warning').hide();
|
$(modal).find('#note-warning').hide();
|
||||||
|
$(modal).find('#confirm-warning').hide();
|
||||||
|
|
||||||
modalEnable(modal, true);
|
modalEnable(modal, true);
|
||||||
|
|
||||||
@ -116,13 +131,23 @@ function updateStock(items, options={}) {
|
|||||||
|
|
||||||
var stocktake = [];
|
var stocktake = [];
|
||||||
var notes = $(modal).find('#stocktake-notes').val();
|
var notes = $(modal).find('#stocktake-notes').val();
|
||||||
|
var confirm = $(modal).find('#stocktake-confirm').is(':checked');
|
||||||
|
|
||||||
|
var valid = true;
|
||||||
|
|
||||||
if (!notes) {
|
if (!notes) {
|
||||||
$(modal).find('#note-warning').show();
|
$(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
|
// Form stocktake data
|
||||||
for (idx = 0; idx < items.length; idx++) {
|
for (idx = 0; idx < items.length; idx++) {
|
||||||
@ -413,6 +438,42 @@ function loadStockTable(table, options) {
|
|||||||
if (options.buttons) {
|
if (options.buttons) {
|
||||||
linkButtonsToSelection(table, 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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,24 +44,7 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div id='button-toolbar'>
|
{% include "stock_table.html" %}
|
||||||
<div class='button-toolbar container-fluid' style='float: right;'>
|
|
||||||
<button class="btn btn-success" id='item-create'>New Stock Item</button>
|
|
||||||
<div class="dropdown" style='float: right;'>
|
|
||||||
<button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options<span class="caret"></span></button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a href="#" id='multi-item-add' title='Add to selected stock items'>Add stock</a></li>
|
|
||||||
<li><a href="#" id='multi-item-remove' title='Remove from selected stock items'>Remove stock</a></li>
|
|
||||||
<li><a href="#" id='multi-item-stocktake' title='Stocktake selected stock items'>Stocktake</a></li>
|
|
||||||
<li><a href='#' id='multi-item-move' title='Move selected stock items'>Move</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='stock-table'>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
{% include 'modals.html' %}
|
{% include 'modals.html' %}
|
||||||
|
|
||||||
@ -149,46 +132,7 @@
|
|||||||
|
|
||||||
return false;
|
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"), {
|
loadStockTable($("#stock-table"), {
|
||||||
buttons: [
|
buttons: [
|
||||||
'#stock-options',
|
'#stock-options',
|
||||||
|
17
InvenTree/templates/stock_table.html
Normal file
17
InvenTree/templates/stock_table.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<div id='button-toolbar'>
|
||||||
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
|
<button class="btn btn-success" id='item-create'>New Stock Item</button>
|
||||||
|
<div class="dropdown" style='float: right;'>
|
||||||
|
<button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="#" id='multi-item-add' title='Add to selected stock items'>Add stock</a></li>
|
||||||
|
<li><a href="#" id='multi-item-remove' title='Remove from selected stock items'>Remove stock</a></li>
|
||||||
|
<li><a href="#" id='multi-item-stocktake' title='Stocktake selected stock items'>Stocktake</a></li>
|
||||||
|
<li><a href='#' id='multi-item-move' title='Move selected stock items'>Move</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='stock-table'>
|
||||||
|
</table>
|
Loading…
x
Reference in New Issue
Block a user