Add part stocktake to Stock Location page(s)

This commit is contained in:
Oliver 2018-05-08 22:41:52 +10:00
parent f2982a59ad
commit bf4ffb8b0b
3 changed files with 28 additions and 17 deletions

View File

@ -7,15 +7,11 @@ function deleteButton(url, text='Delete') {
}
function renderLink(text, url) {
if (text && url) {
return '<a href="' + url + '">' + text + '</a>';
}
else if (text) {
if (text === '' || url === '') {
return text;
}
else {
return '';
}
return '<a href="' + url + '">' + text + '</a>';
}

View File

@ -194,8 +194,6 @@ class StockItem(models.Model):
@property
def in_stock(self):
if self.quantity == 0:
return False
if self.belongs_to or self.customer:
return False
@ -284,6 +282,9 @@ class StockItem(models.Model):
""" Remove items from stock
"""
if self.quantity == 0:
return
quantity = int(quantity)
if quantity <= 0 or self.infinite:

View File

@ -47,6 +47,8 @@
<button 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>
@ -130,16 +132,28 @@
return false;
});
$("#multi-item-stocktake").click(function() {
var items = selectedStock();
function _stock(action) {
adjustStock({
action: action,
items: selectedStock(),
success: function() {
$('#stock-table').bootstrapTable('refresh');
}
})
}
countStockItems(items,
{
success: function() {
$("#stock-table").bootstrapTable('refresh');
}
});
$('#multi-item-stocktake').click(function() {
_stock('stocktake');
return false;
});
$('#multi-item-remove').click(function() {
_stock('remove');
return false;
});
$('#multi-item-add').click(function() {
_stock('add');
return false;
});