Use 'on_order' count in calculation for parts we need to order

This commit is contained in:
Oliver Walters 2019-06-10 23:05:14 +10:00
parent 04a9b1a980
commit 3954b33fb7
3 changed files with 7 additions and 3 deletions

View File

@ -21,6 +21,7 @@ class PurchaseOrderLineItemAdmin(admin.ModelAdmin):
list_display = ( list_display = (
'order', 'order',
'part',
'quantity', 'quantity',
'reference' 'reference'
) )

View File

@ -427,7 +427,7 @@ class Part(models.Model):
then we need to restock. then we need to restock.
""" """
return (self.total_stock - self.allocation_count) < self.minimum_stock return (self.total_stock + self.on_order - self.allocation_count) < self.minimum_stock
@property @property
def can_build(self): def can_build(self):
@ -816,6 +816,7 @@ class Part(models.Model):
return [order for order in self.purchase_orders() if order.status not in OrderStatus.OPEN] return [order for order in self.purchase_orders() if order.status not in OrderStatus.OPEN]
@property
def on_order(self): def on_order(self):
""" Return the total number of items on order for this part. """ """ Return the total number of items on order for this part. """

View File

@ -2,16 +2,18 @@
<tr> <tr>
<th>Part</th> <th>Part</th>
<th>Description</th> <th>Description</th>
<th>Required</th>
<th>In Stock</th> <th>In Stock</th>
<th>Allocated</th> <th>On Order</th>
<th>Net Stock</th> <th>Net Stock</th>
</tr> </tr>
{% for part in parts %} {% for part in parts %}
<tr> <tr>
<td><a href="{% url 'part-detail' part.id %}">{{ part.full_name }}</a></td> <td><a href="{% url 'part-detail' part.id %}">{{ part.full_name }}</a></td>
<td>{{ part.description }}</td> <td>{{ part.description }}</td>
<td>{{ part.total_stock }}</td>
<td>{{ part.allocation_count }}</td> <td>{{ part.allocation_count }}</td>
<td>{{ part.total_stock }}</td>
<td>{{ part.on_order }}</td>
<td>{{ part.available_stock }}</td> <td>{{ part.available_stock }}</td>
</tr> </tr>
{% endfor %} {% endfor %}