mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cleanup
This commit is contained in:
parent
59f102af3c
commit
36ec5e41b0
@ -15,6 +15,13 @@
|
||||
supplier: 1
|
||||
SKU: 'ACME0002'
|
||||
|
||||
- model: company.supplierpart
|
||||
pk: 3
|
||||
fields:
|
||||
part: 1
|
||||
supplier: 1
|
||||
SKU: 'ACME0003'
|
||||
|
||||
# Widget purchaseable from ACME
|
||||
- model: company.supplierpart
|
||||
pk: 100
|
||||
@ -33,7 +40,7 @@
|
||||
|
||||
# M2x4 LPHS from Zerg Corp
|
||||
- model: company.supplierpart
|
||||
pk: 3
|
||||
pk: 7
|
||||
fields:
|
||||
part: 1
|
||||
supplier: 3
|
||||
|
@ -35,8 +35,16 @@
|
||||
quantity: 250
|
||||
received: 50
|
||||
|
||||
# 1000 x ACME0003
|
||||
- model: order.purchaseorderlineitem
|
||||
fields:
|
||||
order: 1
|
||||
part: 3
|
||||
quantity: 1000
|
||||
|
||||
# 100 x ZERGLPHS (M2x4 LPHS)
|
||||
- model: order.purchaseorderlineitem
|
||||
pk: 22
|
||||
fields:
|
||||
order: 2
|
||||
part: 3
|
||||
|
@ -137,7 +137,7 @@ class POTests(OrderViewTestCase):
|
||||
|
||||
# POST with a part that does not match the purchase order
|
||||
post_data['order'] = 1
|
||||
post_data['part'] = 3
|
||||
post_data['part'] = 7
|
||||
response = self.client.post(url, post_data, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
data = json.loads(response.content)
|
||||
self.assertFalse(data['form_valid'])
|
||||
@ -169,3 +169,18 @@ class POTests(OrderViewTestCase):
|
||||
|
||||
response = self.client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestPOReceive(OrderViewTestCase):
|
||||
""" Tests for receiving a purchase order """
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.po = PurchaseOrder.objects.get(pk=1)
|
||||
self.url = reverse('purchase-order-receive', args=(1,))
|
||||
|
||||
def test_receive_lines(self):
|
||||
|
||||
# TODO
|
||||
pass
|
||||
|
@ -101,7 +101,7 @@ class OrderTest(TestCase):
|
||||
loc = StockLocation.objects.get(id=1)
|
||||
|
||||
# There should be two lines against this order
|
||||
self.assertEqual(len(order.pending_line_items()), 2)
|
||||
self.assertEqual(len(order.pending_line_items()), 3)
|
||||
|
||||
# Should fail, as order is 'PENDING' not 'PLACED"
|
||||
self.assertEqual(order.status, OrderStatus.PENDING)
|
||||
@ -117,7 +117,7 @@ class OrderTest(TestCase):
|
||||
|
||||
self.assertEqual(line.remaining(), 50)
|
||||
|
||||
self.assertEqual(part.on_order, 350)
|
||||
self.assertEqual(part.on_order, 1350)
|
||||
|
||||
# Try to order some invalid things
|
||||
with self.assertRaises(django_exceptions.ValidationError):
|
||||
|
@ -243,6 +243,11 @@ class PurchaseOrderReceive(AjaxView):
|
||||
except (PurchaseOrderLineItem.DoesNotExist, ValueError):
|
||||
continue
|
||||
|
||||
# Check that line matches the order
|
||||
if not line.order == self.order:
|
||||
# TODO - Display a non-field error?
|
||||
continue
|
||||
|
||||
# Ignore a part that doesn't map to a SupplierPart
|
||||
try:
|
||||
if line.part is None:
|
||||
@ -277,6 +282,7 @@ class PurchaseOrderReceive(AjaxView):
|
||||
|
||||
return self.renderJsonResponse(request, data=data)
|
||||
|
||||
@transaction.atomic
|
||||
def receive_parts(self):
|
||||
""" Called once the form has been validated.
|
||||
Create new stockitems against received parts.
|
||||
|
Loading…
Reference in New Issue
Block a user