mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
Sales order barcode allocate (#6072)
* Bug fix for BarcodePOReceive endpoint - Existing scan must match "stockitem" to raise an error * bug fix: barcode.js - Handle new return data from barcode scan endpoint * Add barcode endpoint for allocating stock to sales order * Improve logic for preventing over allocation of stock item to sales order * Test for sufficient quantity * Bump API version * Bug fix and extra check * Cleanup unit tests * Add unit testing for new endpoint * Add blank page for app sales orders docs * Add docs for new barcode features in app * Fix unit tests * Remove debug statement
This commit is contained in:
@ -137,6 +137,37 @@ class SalesOrderTest(TestCase):
|
||||
quantity=25 if full else 20
|
||||
)
|
||||
|
||||
def test_over_allocate(self):
|
||||
"""Test that over allocation logic works"""
|
||||
|
||||
SA = StockItem.objects.create(part=self.part, quantity=9)
|
||||
|
||||
# First three allocations should succeed
|
||||
for _i in range(3):
|
||||
allocation = SalesOrderAllocation.objects.create(
|
||||
line=self.line,
|
||||
item=SA,
|
||||
quantity=3,
|
||||
shipment=self.shipment
|
||||
)
|
||||
|
||||
# Editing an existing allocation with a larger quantity should fail
|
||||
with self.assertRaises(ValidationError):
|
||||
allocation.quantity = 4
|
||||
allocation.save()
|
||||
allocation.clean()
|
||||
|
||||
# Next allocation should fail
|
||||
with self.assertRaises(ValidationError):
|
||||
allocation = SalesOrderAllocation.objects.create(
|
||||
line=self.line,
|
||||
item=SA,
|
||||
quantity=3,
|
||||
shipment=self.shipment
|
||||
)
|
||||
|
||||
allocation.clean()
|
||||
|
||||
def test_allocate_partial(self):
|
||||
"""Partially allocate stock"""
|
||||
self.allocate_stock(False)
|
||||
|
Reference in New Issue
Block a user