2
0
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:
Oliver
2023-12-14 11:13:50 +11:00
committed by GitHub
parent 3410534f29
commit 99c92ff655
16 changed files with 569 additions and 52 deletions

View File

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