Skip to content

Commit

Permalink
Fix location priority when receiving items (#5661) (#5663)
Browse files Browse the repository at this point in the history
* Fix location priority when receiving items

Fixes POReceiveBarcodeHandler

* Unit test adjustment

(cherry picked from commit 4b13f3b)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat committed Oct 4, 2023
1 parent a7487ff commit 86542bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions InvenTree/order/serializers.py
Expand Up @@ -674,8 +674,8 @@ def save(self):
with transaction.atomic():
for item in items:

# Select location
loc = item.get('location', None) or item['line_item'].get_destination() or location
# Select location (in descending order of priority)
loc = location or item.get('location', None) or item['line_item'].get_destination()

try:
order.receive_line_item(
Expand Down Expand Up @@ -879,7 +879,7 @@ class Meta:
]

def __init__(self, *args, **kwargs):
"""Initializion routine for the serializer:
"""Initialization routine for the serializer:
- Add extra related serializer information if required
"""
Expand Down
12 changes: 6 additions & 6 deletions InvenTree/order/test_api.py
Expand Up @@ -982,9 +982,9 @@ def test_valid(self):
self.assertEqual(stock_1.count(), 1)
self.assertEqual(stock_2.count(), 1)

# Different location for each received item
# Same location for each received item, as overall 'location' field is provided
self.assertEqual(stock_1.last().location.pk, 1)
self.assertEqual(stock_2.last().location.pk, 2)
self.assertEqual(stock_2.last().location.pk, 1)

# Barcodes should have been assigned to the stock items
self.assertTrue(StockItem.objects.filter(barcode_data='MY-UNIQUE-BARCODE-123').exists())
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def test_download_xls(self):
self.assertTrue(isinstance(file, io.BytesIO))

def test_download_csv(self):
"""Tesst that the list of sales orders can be downloaded as a .csv file"""
"""Test that the list of sales orders can be downloaded as a .csv file"""
url = reverse('api-so-list')

required_cols = [
Expand Down Expand Up @@ -1809,7 +1809,7 @@ def test_shipment_complete(self):
self.assertEqual(self.shipment.delivery_date, datetime(2023, 12, 5).date())
self.assertTrue(self.shipment.is_delivered())

def test_shipment_deliverydate(self):
def test_shipment_delivery_date(self):
"""Test delivery date functions via API."""
url = reverse('api-so-shipment-detail', kwargs={'pk': self.shipment.pk})

Expand Down Expand Up @@ -1854,7 +1854,7 @@ def test_sales_order_shipment_list(self):
url = reverse('api-so-shipment-list')

# Count before creation
countbefore = models.SalesOrderShipment.objects.count()
count_before = models.SalesOrderShipment.objects.count()

# Create some new shipments via the API
for order in models.SalesOrder.objects.all():
Expand Down Expand Up @@ -1885,7 +1885,7 @@ def test_sales_order_shipment_list(self):
# List *all* shipments
response = self.get(url, expected_code=200)

self.assertEqual(len(response.data), countbefore + 3 * models.SalesOrder.objects.count())
self.assertEqual(len(response.data), count_before + 3 * models.SalesOrder.objects.count())


class ReturnOrderTests(InvenTreeAPITestCase):
Expand Down

0 comments on commit 86542bc

Please sign in to comment.