mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 11:10:54 +00:00
Assign multiple stock items to a customer at one
This commit is contained in:
@ -568,6 +568,10 @@ class StockAssignmentItemSerializer(serializers.Serializer):
|
||||
if not item.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
|
||||
if item.sales_order_allocations.count() > 0:
|
||||
raise ValidationError(_("Item is allocated to a sales order"))
|
||||
@ -655,6 +659,7 @@ class StockAssignmentSerializer(serializers.Serializer):
|
||||
notes=notes,
|
||||
)
|
||||
|
||||
|
||||
class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||
"""
|
||||
Serializer for a single StockItem within a stock adjument request.
|
||||
|
@ -818,7 +818,7 @@ class StockAssignTest(StockAPITestCase):
|
||||
|
||||
stock_item = StockItem.objects.create(
|
||||
part=part.models.Part.objects.get(pk=1),
|
||||
quantity=i+5,
|
||||
quantity=i + 5,
|
||||
)
|
||||
|
||||
stock_items.append({
|
||||
@ -829,7 +829,7 @@ class StockAssignTest(StockAPITestCase):
|
||||
|
||||
self.assertEqual(customer.assigned_stock.count(), 0)
|
||||
|
||||
response = self.post(
|
||||
self.post(
|
||||
self.URL,
|
||||
data={
|
||||
'items': stock_items,
|
||||
|
Reference in New Issue
Block a user