mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix on_order calculation
- Take into account the number "received" - Also fix unit tests
This commit is contained in:
parent
6a78f6d451
commit
713d7960a8
@ -130,9 +130,10 @@ class OrderTest(TestCase):
|
|||||||
order.receive_line_item(line, loc, 50, user=None)
|
order.receive_line_item(line, loc, 50, user=None)
|
||||||
|
|
||||||
line = PurchaseOrderLineItem.objects.get(id=2)
|
line = PurchaseOrderLineItem.objects.get(id=2)
|
||||||
order.receive_line_item(line, loc, 2 * line.quantity, user=None)
|
|
||||||
|
|
||||||
self.assertEqual(part.on_order, 1100)
|
order.receive_line_item(line, loc, 500, user=None)
|
||||||
|
|
||||||
|
self.assertEqual(part.on_order, 800)
|
||||||
self.assertEqual(order.status, OrderStatus.PLACED)
|
self.assertEqual(order.status, OrderStatus.PLACED)
|
||||||
|
|
||||||
for line in order.pending_line_items():
|
for line in order.pending_line_items():
|
||||||
|
@ -925,14 +925,20 @@ class Part(models.Model):
|
|||||||
""" Return the total number of items on order for this part. """
|
""" Return the total number of items on order for this part. """
|
||||||
|
|
||||||
orders = self.supplier_parts.filter(purchase_order_line_items__order__status__in=OrderStatus.OPEN).aggregate(
|
orders = self.supplier_parts.filter(purchase_order_line_items__order__status__in=OrderStatus.OPEN).aggregate(
|
||||||
quantity=Sum('purchase_order_line_items__quantity'))
|
quantity=Sum('purchase_order_line_items__quantity'),
|
||||||
|
received=Sum('purchase_order_line_items__received')
|
||||||
|
)
|
||||||
|
|
||||||
quantity = orders['quantity']
|
quantity = orders['quantity']
|
||||||
|
received = orders['received']
|
||||||
|
|
||||||
if quantity is None:
|
if quantity is None:
|
||||||
quantity = 0
|
quantity = 0
|
||||||
|
|
||||||
return quantity
|
if received is None:
|
||||||
|
received = 0
|
||||||
|
|
||||||
|
return quantity - received
|
||||||
|
|
||||||
def get_parameters(self):
|
def get_parameters(self):
|
||||||
""" Return all parameters for this part, ordered by name """
|
""" Return all parameters for this part, ordered by name """
|
||||||
|
Loading…
Reference in New Issue
Block a user