mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 13:56:30 +00:00
Much better rendering and calculation of part allocations
This commit is contained in:
@ -14,7 +14,6 @@ from django.urls import reverse
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Sum
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.db.models import prefetch_related_objects
|
||||
from django.core.validators import MinValueValidator
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
@ -628,7 +627,6 @@ class Part(models.Model):
|
||||
|
||||
return query['total']
|
||||
|
||||
|
||||
def allocation_count(self):
|
||||
"""
|
||||
Return the total quantity of stock allocated for this part,
|
||||
|
@ -1,6 +1,7 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load status_codes %}
|
||||
{% load i18n %}
|
||||
{% load inventree_extras %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
@ -10,17 +11,22 @@
|
||||
|
||||
<table class='table table-striped table-condensed' id='build-table'>
|
||||
<tr>
|
||||
<th>Build</th>
|
||||
<th>Making</th>
|
||||
<th>Allocated</th>
|
||||
<th>Status</th>
|
||||
<th>{% trans "Order" %}</th>
|
||||
<th>{% trans "Stock Item" %}</th>
|
||||
<th>{% trans "Quantity" %}</th>
|
||||
</tr>
|
||||
{% for allocation in part.build_allocation %}
|
||||
{% for allocation in part.build_order_allocations %}
|
||||
<tr>
|
||||
<td><a href="{% url 'build-detail' allocation.build.id %}">{{ allocation.build.title }}</a></td>
|
||||
<td>{{ allocation.build.quantity }} × <a href="{% url 'part-detail' allocation.build.part.id %}">{{ allocation.build.part.full_name }}</a></td>
|
||||
<td>{{ allocation.quantity }}</td>
|
||||
<td>{% build_status_label allocation.build.status %}</td>
|
||||
<td><a href="{% url 'build-detail' allocation.build.id %}">{% trans "Build Order" %}: {{ allocation.build.pk }}</a></td>
|
||||
<td><a href="{% url 'stock-item-detail' allocation.stock_item.id %}">{% trans "Stock Item" %}: {{ allocation.stock_item.id }}</a></td>
|
||||
<td>{% decimal allocation.quantity %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for allocation in part.sales_order_allocations %}
|
||||
<tr>
|
||||
<td><a href="{% url 'so-detail' allocation.line.order.id %}">{% trans "Sales Order" %}: {{ allocation.line.order.pk }}</a></td>
|
||||
<td><a href="{% url 'stock-item-detail' allocation.item.id %}">{% trans "Stock Item" %}: {{ allocation.item.id }}</a></td>
|
||||
<td>{% decimal allocation.quantity %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
@ -32,23 +38,16 @@
|
||||
$("#build-table").inventreeTable({
|
||||
columns: [
|
||||
{
|
||||
title: 'Build',
|
||||
title: '{% trans "Order" %}',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: 'Making',
|
||||
title: '{% trans "Stock Item" %}',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: 'Allocated',
|
||||
sortable: false,
|
||||
formatter: function(value, row, index, field) {
|
||||
return parseFloat(value);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Status',
|
||||
sortable: false,
|
||||
title: '{% trans "Quantity" %}',
|
||||
sortable: true,
|
||||
}
|
||||
]
|
||||
});
|
||||
|
Reference in New Issue
Block a user