2
0
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:
Oliver
2021-12-09 00:32:50 +11:00
parent 96a885e4e1
commit 4a453b0a35
4 changed files with 21 additions and 4 deletions

View File

@ -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.

View File

@ -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,