mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 20:46:47 +00:00
Assign multiple stock items to a customer at one
This commit is contained in:
parent
96a885e4e1
commit
4a453b0a35
@ -568,6 +568,10 @@ class StockAssignmentItemSerializer(serializers.Serializer):
|
|||||||
if not item.in_stock:
|
if not item.in_stock:
|
||||||
raise ValidationError(_("Item must be in stock"))
|
raise ValidationError(_("Item must be in stock"))
|
||||||
|
|
||||||
|
# The base part must be "salable"
|
||||||
|
if not item.part.salable:
|
||||||
|
raise ValidationError(_("Part must be salable"))
|
||||||
|
|
||||||
# The item must not be allocated to a sales order
|
# The item must not be allocated to a sales order
|
||||||
if item.sales_order_allocations.count() > 0:
|
if item.sales_order_allocations.count() > 0:
|
||||||
raise ValidationError(_("Item is allocated to a sales order"))
|
raise ValidationError(_("Item is allocated to a sales order"))
|
||||||
@ -655,6 +659,7 @@ class StockAssignmentSerializer(serializers.Serializer):
|
|||||||
notes=notes,
|
notes=notes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StockAdjustmentItemSerializer(serializers.Serializer):
|
class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||||
"""
|
"""
|
||||||
Serializer for a single StockItem within a stock adjument request.
|
Serializer for a single StockItem within a stock adjument request.
|
||||||
|
@ -818,7 +818,7 @@ class StockAssignTest(StockAPITestCase):
|
|||||||
|
|
||||||
stock_item = StockItem.objects.create(
|
stock_item = StockItem.objects.create(
|
||||||
part=part.models.Part.objects.get(pk=1),
|
part=part.models.Part.objects.get(pk=1),
|
||||||
quantity=i+5,
|
quantity=i + 5,
|
||||||
)
|
)
|
||||||
|
|
||||||
stock_items.append({
|
stock_items.append({
|
||||||
@ -829,7 +829,7 @@ class StockAssignTest(StockAPITestCase):
|
|||||||
|
|
||||||
self.assertEqual(customer.assigned_stock.count(), 0)
|
self.assertEqual(customer.assigned_stock.count(), 0)
|
||||||
|
|
||||||
response = self.post(
|
self.post(
|
||||||
self.URL,
|
self.URL,
|
||||||
data={
|
data={
|
||||||
'items': stock_items,
|
'items': stock_items,
|
||||||
|
@ -651,7 +651,7 @@ function assignStockToCustomer(items, options={}) {
|
|||||||
// Does the row exist in the form?
|
// Does the row exist in the form?
|
||||||
var row = $(opts.modal).find(`#stock_item_${pk}`);
|
var row = $(opts.modal).find(`#stock_item_${pk}`);
|
||||||
|
|
||||||
if (row) {
|
if (row.exists()) {
|
||||||
item_pk_values.push(pk);
|
item_pk_values.push(pk);
|
||||||
|
|
||||||
data.items.push({
|
data.items.push({
|
||||||
@ -931,7 +931,7 @@ function adjustStock(action, items, options={}) {
|
|||||||
// Does the row exist in the form?
|
// Does the row exist in the form?
|
||||||
var row = $(opts.modal).find(`#stock_item_${pk}`);
|
var row = $(opts.modal).find(`#stock_item_${pk}`);
|
||||||
|
|
||||||
if (row) {
|
if (row.exists()) {
|
||||||
|
|
||||||
item_pk_values.push(pk);
|
item_pk_values.push(pk);
|
||||||
|
|
||||||
@ -1875,6 +1875,17 @@ function loadStockTable(table, options) {
|
|||||||
stockAdjustment('move');
|
stockAdjustment('move');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#multi-item-assign').click(function() {
|
||||||
|
|
||||||
|
var items = $(table).bootstrapTable('getSelections');
|
||||||
|
|
||||||
|
assignStockToCustomer(items, {
|
||||||
|
success: function() {
|
||||||
|
$(table).bootstrapTable('refresh');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('#multi-item-order').click(function() {
|
$('#multi-item-order').click(function() {
|
||||||
var selections = $(table).bootstrapTable('getSelections');
|
var selections = $(table).bootstrapTable('getSelections');
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
<li><a class='dropdown-item' href="#" id='multi-item-stocktake' title='{% trans "Stocktake selected stock items" %}'><span class='fas fa-check-circle'></span> {% trans "Count stock" %}</a></li>
|
<li><a class='dropdown-item' href="#" id='multi-item-stocktake' title='{% trans "Stocktake selected stock items" %}'><span class='fas fa-check-circle'></span> {% trans "Count stock" %}</a></li>
|
||||||
<li><a class='dropdown-item' href='#' id='multi-item-move' title='{% trans "Move selected stock items" %}'><span class='fas fa-exchange-alt'></span> {% trans "Move stock" %}</a></li>
|
<li><a class='dropdown-item' href='#' id='multi-item-move' title='{% trans "Move selected stock items" %}'><span class='fas fa-exchange-alt'></span> {% trans "Move stock" %}</a></li>
|
||||||
<li><a class='dropdown-item' href='#' id='multi-item-order' title='{% trans "Order selected items" %}'><span class='fas fa-shopping-cart'></span> {% trans "Order stock" %}</a></li>
|
<li><a class='dropdown-item' href='#' id='multi-item-order' title='{% trans "Order selected items" %}'><span class='fas fa-shopping-cart'></span> {% trans "Order stock" %}</a></li>
|
||||||
|
<li><a class='dropdown-item' href='#' id='multi-item-assign' title='{% trans "Assign to customer" %}'><span class='fas fa-user-tie'></span> {% trans "Assign to customer" %}</a></li>
|
||||||
<li><a class='dropdown-item' href='#' id='multi-item-set-status' title='{% trans "Change status" %}'><span class='fas fa-exclamation-circle'></span> {% trans "Change stock status" %}</a></li>
|
<li><a class='dropdown-item' href='#' id='multi-item-set-status' title='{% trans "Change status" %}'><span class='fas fa-exclamation-circle'></span> {% trans "Change stock status" %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if roles.stock.delete %}
|
{% if roles.stock.delete %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user