remove from stock now works

This commit is contained in:
Oliver Walters 2019-06-02 12:15:44 +10:00
parent 1b3ffada6d
commit d365d7cc44
3 changed files with 5 additions and 6 deletions

View File

@ -571,10 +571,7 @@ function loadStockTable(table, options) {
});
$('#multi-item-remove').click(function() {
updateStockItems({
action: 'remove',
});
return false;
stockAdjustment('take');
});
$('#multi-item-add').click(function() {

View File

@ -23,7 +23,7 @@
<td>
<input class='numberinput'
min='0'
{% if stock_action == 'move' %} max='{{ item.quantity }}' {% endif %}
{% if stock_action == 'take' or stock_action == 'move' %} max='{{ item.quantity }}' {% endif %}
value='{{ item.new_quantity }}' type='number' name='stock-id-{{ item.id }}' id='stock-id-{{ item.id }}'/>
{% if item.error %}
<br><span class='help-inline'>{{ item.error }}</span>

View File

@ -277,7 +277,7 @@ class StockAdjust(AjaxView, FormMixin):
valid = False
continue
if self.stock_action in ['move']:
if self.stock_action in ['move', 'take']:
if item.new_quantity > item.quantity:
item.error = _('Quantity must not exceed {x}'.format(x=item.quantity))
@ -351,6 +351,8 @@ class StockAdjust(AjaxView, FormMixin):
if item.new_quantity <= 0:
continue
item.take_stock(item.new_quantity, self.request.user, notes=note)
count += 1
return _("Removed stock from {n} items".format(n=count))