mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
List purchase orders for a given part
This commit is contained in:
@ -794,6 +794,18 @@ class Part(models.Model):
|
||||
|
||||
return n
|
||||
|
||||
def purchase_orders(self):
|
||||
""" Return a list of purchase orders which reference this part """
|
||||
|
||||
orders = []
|
||||
|
||||
for part in self.supplier_parts.all().prefetch_related('purchase_order_line_items'):
|
||||
for order in part.purchase_orders():
|
||||
if order not in orders:
|
||||
orders.append(order)
|
||||
|
||||
return orders
|
||||
|
||||
|
||||
def attach_file(instance, filename):
|
||||
""" Function for storing a file for a PartAttachment
|
||||
|
18
InvenTree/part/templates/part/orders.html
Normal file
18
InvenTree/part/templates/part/orders.html
Normal file
@ -0,0 +1,18 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block details %}
|
||||
|
||||
{% include 'part/tabs.html' with tab='orders' %}
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-sm-6'>
|
||||
<h4>Part Orders</h4>
|
||||
</div>
|
||||
<div class='col-sm-6'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "order/po_table.html" with orders=part.purchase_orders %}
|
||||
|
||||
{% endblock %}
|
@ -25,11 +25,17 @@
|
||||
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-used-in' part.id %}">Used In{% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
|
||||
{% endif %}
|
||||
{% if part.purchaseable and part.is_template == False %}
|
||||
{% if part.purchaseable %}
|
||||
{% if part.is_template == False %}
|
||||
<li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-suppliers' part.id %}">Suppliers
|
||||
<span class="badge">{{ part.supplier_count }}</span>
|
||||
</a></li>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li{% ifequal tab 'orders' %} class='active'{% endifequal %}>
|
||||
<a href="{% url 'part-orders' part.id %}">Purchase Orders <span class='badge'>{{ part.purchase_orders|length }}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if part.trackable and 0 %}
|
||||
<li{% ifequal tab 'track' %} class="active"{% endifequal %}>
|
||||
|
@ -34,6 +34,7 @@ part_detail_urls = [
|
||||
url(r'^build/?', views.PartDetail.as_view(template_name='part/build.html'), name='part-build'),
|
||||
url(r'^used/?', views.PartDetail.as_view(template_name='part/used_in.html'), name='part-used-in'),
|
||||
url(r'^suppliers/?', views.PartDetail.as_view(template_name='part/supplier.html'), name='part-suppliers'),
|
||||
url(r'^orders/?', views.PartDetail.as_view(template_name='part/orders.html'), name='part-orders'),
|
||||
url(r'^track/?', views.PartDetail.as_view(template_name='part/track.html'), name='part-track'),
|
||||
url(r'^attachments/?', views.PartDetail.as_view(template_name='part/attachments.html'), name='part-attachments'),
|
||||
|
||||
|
@ -24,6 +24,7 @@ from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDelete
|
||||
from InvenTree.views import QRCodeView
|
||||
|
||||
from InvenTree.helpers import DownloadFile, str2bool
|
||||
from InvenTree.status_codes import OrderStatus
|
||||
|
||||
|
||||
class PartIndex(ListView):
|
||||
@ -446,6 +447,8 @@ class PartDetail(DetailView):
|
||||
|
||||
context['starred'] = part.isStarredBy(self.request.user)
|
||||
|
||||
context['OrderStatus'] = OrderStatus
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user