2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-21 06:16:29 +00:00

Merge pull request #1354 from SchrodingersGat/tree-fix

Sidenav Fixes
This commit is contained in:
Oliver
2021-02-25 09:45:56 +11:00
committed by GitHub
109 changed files with 20652 additions and 4365 deletions

View File

@ -325,6 +325,35 @@ class Part(MPTTModel):
# For legacy reasons the 'variant_of' field is used to indicate the MPTT parent
parent_attr = 'variant_of'
def get_context_data(self, request, **kwargs):
"""
Return some useful context data about this part for template rendering
"""
context = {}
context['starred'] = self.isStarredBy(request.user)
context['disabled'] = not self.active
# Pre-calculate complex queries so they only need to be performed once
context['total_stock'] = self.total_stock
context['quantity_being_built'] = self.quantity_being_built
context['required_build_order_quantity'] = self.required_build_order_quantity()
context['allocated_build_order_quantity'] = self.build_order_allocation_count()
context['required_sales_order_quantity'] = self.required_sales_order_quantity()
context['allocated_sales_order_quantity'] = self.sales_order_allocation_count()
context['available'] = self.available_stock
context['on_order'] = self.on_order
context['required'] = context['required_build_order_quantity'] + context['required_sales_order_quantity']
context['allocated'] = context['allocated_build_order_quantity'] + context['allocated_sales_order_quantity']
return context
def save(self, *args, **kwargs):
"""
Overrides the save() function for the Part model.

View File

@ -3,12 +3,15 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" with tab="allocation" %}
{% endblock %}
{% block heading %}
{% trans "Part Stock Allocations" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab="allocation" %}
<h4>{% trans "Part Stock Allocations" %}</h4>
<table class='table table-striped table-condensed' id='build-table'>
<tr>
<th>{% trans "Order" %}</th>
@ -34,6 +37,7 @@
{% endblock %}
{% block js_ready %}
{{ block.super }}
$("#build-table").inventreeTable({
columns: [

View File

@ -1,14 +1,17 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='attachments' %}
{% endblock %}
{% block heading %}
{% trans "Part Attachments" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='attachments' %}
<h4>{% trans "Part Attachments" %}</h4>
<hr>
{% include "attachment_table.html" with attachments=part.part_attachments %}
{% endblock %}

View File

@ -2,17 +2,15 @@
{% load static %}
{% load i18n %}
{% block css %}
{% block menubar %}
{% include 'part/navbar.html' with tab='bom' %}
{% endblock %}
{% block heading %}
{% trans "Bill of Materials" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='bom' %}
<h4>{% trans "Bill of Materials" %}</h4>
<hr>
{% if part.bom_checked_date %}
{% if part.is_bom_valid %}
<div class='alert alert-block alert-info'>

View File

@ -3,9 +3,15 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" with tab='bom' %}
{% endblock %}
{% block heading %}
{% trans "Upload Bill of Materials" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab='bom' %}
<h4>{% trans "Upload Bill of Materials" %}</h4>
<p>{% trans "Step 2 - Select Fields" %}</p>
<hr>

View File

@ -3,9 +3,15 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" with tab="bom" %}
{% endblock %}
{% block heading %}
{% trans "Upload Bill of Materials" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab="bom" %}
<h4>{% trans "Upload Bill of Materials" %}</h4>
<p>{% trans "Step 3 - Select Parts" %}</p>
<hr>

View File

@ -3,13 +3,16 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" with tab='bom' %}
{% endblock %}
{% block heading %}
{% trans "Upload Bill of Materials" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab='bom' %}
<h4>{% trans "Upload Bill of Materials" %}</h4>
<hr>
<p>{% trans "Step 1 - Select BOM File" %}</p>
<div class='alert alert-info alert-block'>

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='build' %}
{% endblock %}
{% block heading %}
{% trans "Part Builds" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='build' %}
<h4>{% trans "Part Builds" %}</h4>
<hr>
<div id='button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right';>
{% if part.active %}

View File

@ -4,107 +4,109 @@
{% block content %}
<div class='row'>
<div class='col-sm-6'>
{% if category %}
<h3>
{{ category.name }}
{% if user.is_staff and roles.part_category.change %}
<a href="{% url 'admin:part_partcategory_change' category.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
<div class='panel panel-default panel-inventree'>
<div class='row'>
<div class='col-sm-6'>
{% if category %}
<h3>
{{ category.name }}
{% if user.is_staff and roles.part_category.change %}
<a href="{% url 'admin:part_partcategory_change' category.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
</h3>
<p>{{ category.description }}</p>
{% else %}
<h3>{% trans "Part Categories" %}</h3>
<p>{% trans "All parts" %}</p>
{% endif %}
</h3>
<p>{{ category.description }}</p>
{% else %}
<h3>{% trans "Part Categories" %}</h3>
<p>{% trans "All parts" %}</p>
{% endif %}
<p>
<div class='btn-group action-buttons'>
{% if roles.part_category.add %}
<button class='btn btn-default' id='cat-create' title='{% trans "Create new part category" %}'>
<span class='fas fa-plus-circle icon-green'/>
</button>
<p>
<div class='btn-group action-buttons'>
{% if roles.part_category.add %}
<button class='btn btn-default' id='cat-create' title='{% trans "Create new part category" %}'>
<span class='fas fa-plus-circle icon-green'/>
</button>
{% endif %}
{% if category %}
{% if roles.part_category.change %}
<button class='btn btn-default' id='cat-edit' title='{% trans "Edit part category" %}'>
<span class='fas fa-edit icon-blue'/>
</button>
{% endif %}
{% if roles.part_category.delete %}
<button class='btn btn-default' id='cat-delete' title='{% trans "Delete part category" %}'>
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
{% endif %}
</div>
</p>
</div>
<div class='col-sm-6'>
{% if category %}
<h3>{% trans "Category Details" %}</h3>
<table class='table table-condensed table-striped'>
<col width='25'>
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Category Path" %}</td>
<td>{{ category.pathstring }}</td>
</tr>
<tr>
<td><span class='fas fa-info-circle'></span></td>
<td>{% trans "Category Description" %}</td>
<td>{{ category.description }}</td>
</tr>
{% if category.default_location %}
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Default Location" %}</td>
<td><a href="{% url 'stock-location-detail' category.default_location.pk %}">{{ category.default_location.pathstring }}</a></td>
</tr>
{% endif %}
{% if category %}
{% if roles.part_category.change %}
<button class='btn btn-default' id='cat-edit' title='{% trans "Edit part category" %}'>
<span class='fas fa-edit icon-blue'/>
</button>
{% if category.default_keywords %}
<tr>
<td><span class='fas fa-key'></span></td>
<td>{% trans "Keywords" %}</td>
<td>{{ category.default_keywords }}</td>
</tr>
{% endif %}
{% if roles.part_category.delete %}
<button class='btn btn-default' id='cat-delete' title='{% trans "Delete part category" %}'>
<span class='fas fa-trash-alt icon-red'/>
</button>
{% endif %}
{% endif %}
</div>
</p>
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Subcategories" %}</td>
<td>{{ category.children.count }}</td>
</tr>
<tr>
<td><span class='fas fa-shapes'></span></td>
<td>{% trans "Parts (Including subcategories)" %}</td>
<td>{{ category.partcount }}</td>
</tr>
</table>
{% else %}
<h3>{% trans "Category Details" %}</h3>
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Part Categories" %}</td>
<td>{{ category_count }}</td>
</tr>
<tr>
<td><span class='fas fa-shapes'></span></td>
<td>{% trans "Parts" %}</td>
<td>{{ part_count }}</td>
</tr>
</table>
{% endif %}
</div>
</div>
<div class='col-sm-6'>
{% if category %}
<h3>{% trans "Category Details" %}</h3>
<table class='table table-condensed table-striped'>
<col width='25'>
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Category Path" %}</td>
<td>{{ category.pathstring }}</td>
</tr>
<tr>
<td><span class='fas fa-info-circle'></span></td>
<td>{% trans "Category Description" %}</td>
<td>{{ category.description }}</td>
</tr>
{% if category.default_location %}
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "Default Location" %}</td>
<td><a href="{% url 'stock-location-detail' category.default_location.pk %}">{{ category.default_location.pathstring }}</a></td>
</tr>
{% endif %}
{% if category.default_keywords %}
<tr>
<td><span class='fas fa-key'></span></td>
<td>{% trans "Keywords" %}</td>
<td>{{ category.default_keywords }}</td>
</tr>
{% endif %}
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Subcategories" %}</td>
<td>{{ category.children.count }}</td>
</tr>
<tr>
<td><span class='fas fa-shapes'></span></td>
<td>{% trans "Parts (Including subcategories)" %}</td>
<td>{{ category.partcount }}</td>
</tr>
</table>
{% else %}
<h3>{% trans "Category Details" %}</h3>
<table class='table table-striped table-condensed'>
<col width='25'>
<tr>
<td><span class='fas fa-sitemap'></span></td>
<td>{% trans "Part Categories" %}</td>
<td>{{ category_count }}</td>
</tr>
<tr>
<td><span class='fas fa-shapes'></span></td>
<td>{% trans "Parts" %}</td>
<td>{{ part_count }}</td>
</tr>
</table>
{% endif %}
</div>
</div>
{% if category and category.children.all|length > 0 %}
{% include "part/subcategories.html" with children=category.children.all collapse_id="categories" %}
{% elif children|length > 0 %}
{% include "part/subcategories.html" with children=children collapse_id="categories" %}
{% endif %}
<hr>
{% if category and category.children.all|length > 0 %}
{% include "part/subcategories.html" with children=category.children.all collapse_id="categories" %}
{% elif children|length > 0 %}
{% include "part/subcategories.html" with children=children collapse_id="categories" %}
{% endif %}
</div>
<div id='button-toolbar'>
<div class='btn-group'>
@ -132,19 +134,40 @@
</div>
</div>
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>
{% block heading %}
<!-- Heading goes here -->
{% endblock %}
</h4>
</div>
<div class='panel-content'>
{% block details %}
<!-- Content goes here -->
{% endblock %}
</div>
</div>
{% block category_tables %}
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
</table>
{% endblock category_tables %}
{% endblock %}
{% block js_load %}
{{ block.super }}
{% endblock %}
{% block js_ready %}
{{ block.super }}
{% if category %}
enableNavbar({
label: 'category',
toggleId: '#category-menu-toggle',
});
{% endif %}
if (inventreeLoadInt("show-part-cats") == 1) {
$("#collapse-item-categories").collapse('show');
}

View File

@ -0,0 +1,24 @@
{% load i18n %}
<ul class='list-group'>
<li class='list-group-item'>
<a href='#' id='category-menu-toggle'>
<span class='menu-tab-icon fas fa-expand-arrows-alt'></span>
</a>
</li>
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Parts" %}'>
<a href='{% url "category-detail" category.id %}'>
<span class='fas fa-shapes'></span>
{% trans "Parts" %}
</a>
</li>
<li class='list-group-item {% if tab == "parameters" %}active{% endif %}' title='{% trans "Parameters" %}'>
<a href='{% url "category-parametric" category.id %}'>
<span class='fas fa-tasks'></span>
{% trans "Parameters" %}
</a>
</li>
</ul>

View File

@ -2,9 +2,15 @@
{% load static %}
{% load i18n %}
{% block category_tables %}
{% block menubar %}
{% include 'part/category_navbar.html' with tab='parameters' %}
{% endblock %}
{% include 'part/category_tabs.html' with tab='parametric-table' %}
{% block heading %}
{% trans "Part Parameters" %}
{% endblock %}
{% block details %}
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='parametric-part-table'>
</table>

View File

@ -2,11 +2,15 @@
{% load static %}
{% load i18n %}
{% block category_tables %}
{% include 'part/category_tabs.html' with tab='part-list' %}
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
</table>
{% block menubar %}
{% include 'part/category_navbar.html' with tab='parts' %}
{% endblock %}
{% block heading %}
{% trans "Parts" %}
{% endblock %}
{% block details %}
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='part-table'>
</table>
{% endblock %}

View File

@ -1,11 +0,0 @@
{% load i18n %}
{% load inventree_extras %}
<ul class="nav nav-tabs">
<li{% ifequal tab 'part-list' %} class="active"{% endifequal %}>
<a href="{% url 'category-detail' category.id %}">{% trans "Parts" %} <span class="badge">{% decimal part_count %}</span></a>
</li>
<li{% ifequal tab 'parametric-table' %} class='active'{% endifequal %}>
<a href="{% url 'category-parametric' category.id %}">{% trans "Parametric Table" %}</a>
</li>
</ul>

View File

@ -2,13 +2,16 @@
{% load static %}
{% load i18n %}
{% block details %}
{% include 'part/tabs.html' with tab='detail' %}
{% block menubar %}
{% include 'part/navbar.html' with tab='details' %}
{% endblock %}
<h4>{% trans "Part Details" %}</h4>
{% block heading %}
{% trans "Part Details" %}
{% endblock %}
<hr>
{% block details %}
<div class='row'>
<div class='col-sm-6'>

View File

@ -0,0 +1,125 @@
{% load i18n %}
{% load static %}
{% load inventree_extras %}
<ul class='list-group'>
<li class='list-group-item'>
<a href='#' id='part-menu-toggle'>
<span class='menu-tab-icon fas fa-expand-arrows-alt'></span>
</a>
</li>
<li class='list-group-item {% if tab == "details" %}active{% endif %}' title='{% trans "Part Details" %}'>
<a href='{% url "part-detail" part.id %}'>
<span class='menu-tab-icon fas fa-info-circle'></span>
<span class='tab-text'>
{% trans "Details" %}
</span>
</a>
</li>
<li class='list-group-item {% if tab == "params" %}active{% endif %}' title='{% trans "Part Parameters" %}'>
<a href='{% url "part-params" part.id %}'>
<span class='menu-tab-icon fas fa-tasks'></span>
{% trans "Parameters" %}
</a>
</li>
{% if part.is_template %}
<li class='list-group-item {% if tab == "variants" %}active{% endif %}' title='{% trans "Part Variants" %}'>
<a href='{% url "part-variants" part.id %}'>
<span class='menu-tab-icon fas fa-shapes'></span>
{% trans "Variants" %}
</a>
</li>
{% endif %}
<li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
<a href='{% url "part-stock" part.id %}'>
<span class='menu-tab-icon fas fa-boxes'></span>
{% trans "Stock" %}
</a>
</li>
{% if part.component or part.salable %}
<li class='list-group-item {% if tab == "allocation" %}active{% endif %}' title='{% trans "Allocated Stock" %}'>
<a href='{% url "part-allocation" part.id %}'>
<span class='menu-tab-icon fas fa-sign-out-alt'></span>
{% trans "Allocations" %}
</a>
</li>
{% endif %}
{% if part.assembly %}
<li class='list-group-item {% if tab == "bom" %}active{% endif %}' title='{% trans "Bill of Materials" %}'>
<a href='{% url "part-bom" part.id %}'>
<span class='menu-tab-icon fas fa-list'></span>
{% trans "Bill of Materials" %}
</a>
</li>
{% if roles.build.view %}
<li class='list-group-item {% if tab == "build" %}active{% endif %}' title='{% trans "Build Orders" %}'>
<a href='{% url "part-build" part.id %}'>
<span class='menu-tab-icon fas fa-tools'></span>
{% trans "Build Orders" %}
</a>
</li>
{% endif %}
{% endif %}
{% if part.component %}
<li class='list-group-item {% if tab == "used" %}active{% endif %}' title='{% trans "Used In" %}'>
<a href='{% url "part-used-in" part.id %}'>
<span class='menu-tab-icon fas fa-layer-group'></span>
{% trans "Used In" %}
</a>
</li>
{% endif %}
{% if part.purchaseable and roles.purchase_order.view %}
<li class='list-group-item {% if tab == "suppliers" %}active{% endif %}' title='{% trans "Suppliers" %}'>
<a href='{% url "part-suppliers" part.id %}'>
<span class='menu-tab-icon fas fa-building'></span>
{% trans "Suppliers" %}
</a>
</li>
<li class='list-group-item {% if tab == "orders" %}active{% endif %}' title='{% trans "Purchase Orders" %}'>
<a href='{% url "part-orders" part.id %}'>
<span class='menu-tab-icon fas fa-shopping-cart'></span>
{% trans "Purchase Orders" %}
</a>
</li>
{% endif %}
{% if part.salable and roles.sales_order.view %}
<li class='list-group-item {% if tab == "sales-prices" %}active{% endif %}' title='{% trans "Sales Price Information" %}'>
<a href='{% url "part-sale-prices" part.id %}'>
<span class='menu-tab-icon fas fa-dollar-sign'></span>
{% trans "Sale Price" %}
</a>
</li>
<li class='list-group-item {% if tab == "sales-orders" %}active{% endif %}' title='{% trans "Sales Orders" %}'>
<a href='{% url "part-sales-orders" part.id %}'>
<span class='menu-tab-icon fas fa-truck'></span>
{% trans "Sales Orders" %}
</a>
</li>
{% endif %}
{% if part.trackable %}
<li class='list-group-item {% if tab == "tests" %}active{% endif %}' title='{% trans "Part Test Templates" %}'>
<a href='{% url "part-test-templates" part.id %}'>
<span class='menu-tab-icon fas fa-vial'></span>
{% trans "Tests" %}
</a>
</li>
{% endif %}
<li class='list-group-item {% if tab == "related" %}active{% endif %}' title='{% trans "Related Parts" %}'>
<a href='{% url "part-related" part.id %}'>
<span class='menu-tab-icon fas fa-random'></span>
{% trans "Related Parts" %}
</a>
</li>
<li class='list-group-item {% if tab == "attachments" %}active{% endif %}' title='{% trans "Attachments" %}'>
<a href='{% url "part-attachments" part.id %}'>
<span class='menu-tab-icon fas fa-paperclip'></span>
{% trans "Attachments" %}
</a>
</li>
<li class='list-group-item {% if tab == "notes" %}active{% endif %}' title='{% trans "Part Notes" %}'>
<a href='{% url "part-notes" part.id %}'>
<span class='menu-tab-icon fas fa-clipboard'></span>
{% trans "Notes" %}
</a>
</li>
</ul>

View File

@ -4,14 +4,19 @@
{% load i18n %}
{% load markdownify %}
{% block menubar %}
{% include 'part/navbar.html' with tab='notes' %}
{% endblock %}
{% block heading %}
{% trans "Part Notes" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='notes' %}
{% if editing %}
<h4>{% trans "Part Notes" %}</h4>
<hr>
<form method='POST'>
{% csrf_token %}
@ -24,17 +29,10 @@
{{ form.media }}
{% else %}
<div class='row'>
<div class='col-sm-6'>
<h4>{% trans "Part Notes" %}</h4>
</div>
<div class='col-sm-6'>
{% if roles.part.change %}
<button title='{% trans "Edit notes" %}' class='btn btn-default action-button float-right' id='edit-notes'><span class='fas fa-edit'></span></button>
{% endif %}
</div>
</div>
<hr>
{% if roles.part.change %}
<button title='{% trans "Edit notes" %}' class='btn btn-default action-button' id='edit-notes'><span class='fas fa-edit'></span></button>
{% endif %}
<div class='panel panel-default'>
<div class='panel-content'>
{% if part.notes %}

View File

@ -2,13 +2,16 @@
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='orders' %}
{% endblock %}
{% block heading %}
{% trans "Purchase Orders" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='orders' %}
<h4>{% trans "Purchase Orders" %}</h4>
<hr>
<div id='button-bar'>
<div class='button-toolbar container-fluid' style='float: right;'>
<button class='btn btn-primary' type='button' id='part-order2' title='{% trans "Order part" %}'>

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include "part/navbar.html" with tab='params' %}
{% endblock %}
{% block heading %}
{% trans "Part Parameters" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab='params' %}
<h4>{% trans "Part Parameters" %}</h4>
<hr>
<div id='button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
{% if roles.part.add %}

View File

@ -29,6 +29,8 @@ InvenTree | {% trans "Part List" %}
{% block js_ready %}
{{ block.super }}
closeSideNav();
loadTree("{% url 'api-part-tree' %}",
"#part-tree",
{
@ -37,9 +39,10 @@ InvenTree | {% trans "Part List" %}
);
$("#toggle-part-tree").click(function() {
toggleSideNav("#sidenav");
toggleSideNav("#sidenav-left");
return false;
})
});
initSideNav();
{% endblock %}

View File

@ -4,190 +4,196 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" %}
{% endblock %}
{% block content %}
{% if part.virtual %}
<div class='alert alert-info alert-block'>
{% trans "This part is a virtual part" %}
</div>
{% endif %}
{% if part.is_template %}
<div class='alert alert-info alert-block'>
{% trans "This part is a template part." %}
</div>
{% endif %}
<div class='panel panel-default panel-inventree'>
{% if part.variant_of %}
<div class='alert alert-info alert-block'>
{% trans "This part is a variant of" %} <b><a href="{% url 'part-variants' part.variant_of.id %}">{{ part.variant_of.full_name }}</a></b>
</div>
{% endif %}
<div class="row">
<div class="col-sm-6">
{% include "part/part_thumb.html" %}
<div class="media-body">
<h3>
{{ part.full_name }}
{% if user.is_staff and roles.part.change %}
<a href="{% url 'admin:part_part_change' part.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
{% if not part.active %}
<div class='label label-large label-large-red'>
{% trans 'Inactive' %}
</div>
{% endif %}
</h3>
<p><i>{{ part.description }}</i></p>
<div class="row">
<div class="col-sm-6">
{% include "part/part_thumb.html" %}
<div class="media-body">
<h3>
{{ part.full_name }}
{% if user.is_staff and roles.part.change %}
<a href="{% url 'admin:part_part_change' part.pk %}"><span title="{% trans 'Admin view' %}" class='fas fa-user-shield'></span></a>
{% endif %}
{% if not part.active %}
<div class='label label-large label-large-red'>
{% trans 'Inactive' %}
</div>
{% endif %}
</h3>
<p><i>{{ part.description }}</i></p>
<div class='btn-group action-buttons' role='group'>
<button type='button' class='btn btn-default' id='toggle-starred' title='{% trans "Star this part" %}'>
<span id='part-star-icon' class='fas fa-star {% if starred %}icon-yellow{% endif %}'/>
</button>
<div class='btn-group action-buttons' role='group'>
<button type='button' class='btn btn-default' id='toggle-starred' title='{% trans "Star this part" %}'>
<span id='part-star-icon' class='fas fa-star {% if starred %}icon-yellow{% endif %}'/>
</button>
{% if barcodes %}
<!-- Barcode actions menu -->
<div class='btn-group'>
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'>
<li><a href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
</ul>
{% if barcodes %}
<!-- Barcode actions menu -->
<div class='btn-group'>
<button id='barcode-options' title='{% trans "Barcode actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'><span class='fas fa-qrcode'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'>
<li><a href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
</ul>
</div>
{% endif %}
{% if part.active %}
<button type='button' class='btn btn-default' id='price-button' title='{% trans "Show pricing information" %}'>
<span id='part-price-icon' class='fas fa-dollar-sign'/>
</button>
{% if roles.stock.change %}
<button type='button' class='btn btn-default' id='part-count' title='{% trans "Count part stock" %}'>
<span class='fas fa-clipboard-list'/>
</button>
{% endif %}
{% if part.purchaseable %}
{% if roles.purchase_order.add %}
<button type='button' class='btn btn-default' id='part-order' title='{% trans "Order part" %}'>
<span id='part-order-icon' class='fas fa-shopping-cart'/>
</button>
{% endif %}
{% endif %}
{% endif %}
<!-- Part actions -->
{% if roles.part.add or roles.part.change or roles.part.delete %}
<div class='btn-group'>
<button id='part-actions' title='{% trans "Part actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'> <span class='fas fa-shapes'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'>
{% if roles.part.add %}
<li><a href='#' id='part-duplicate'><span class='fas fa-copy'></span> {% trans "Duplicate part" %}</a></li>
{% endif %}
{% if roles.part.change %}
<li><a href='#' id='part-edit'><span class='fas fa-edit icon-blue'></span> {% trans "Edit part" %}</a></li>
{% endif %}
{% if not part.active and roles.part.delete %}
<li><a href='#' id='part-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete part" %}</a></li>
{% endif %}
</ul>
</div>
{% endif %}
</div>
{% endif %}
{% if part.active %}
<button type='button' class='btn btn-default' id='price-button' title='{% trans "Show pricing information" %}'>
<span id='part-price-icon' class='fas fa-dollar-sign'/>
</button>
{% if roles.stock.change %}
<button type='button' class='btn btn-default' id='part-count' title='{% trans "Count part stock" %}'>
<span class='fas fa-clipboard-list'/>
</button>
{% endif %}
{% if part.purchaseable %}
{% if roles.purchase_order.add %}
<button type='button' class='btn btn-default' id='part-order' title='{% trans "Order part" %}'>
<span id='part-order-icon' class='fas fa-shopping-cart'/>
</button>
{% endif %}
{% endif %}
{% endif %}
<!-- Part actions -->
{% if roles.part.add or roles.part.change or roles.part.delete %}
<div class='btn-group'>
<button id='part-actions' title='{% trans "Part actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'> <span class='fas fa-shapes'></span> <span class='caret'></span></button>
<ul class='dropdown-menu'>
{% if roles.part.add %}
<li><a href='#' id='part-duplicate'><span class='fas fa-copy'></span> {% trans "Duplicate part" %}</a></li>
{% endif %}
{% if roles.part.change %}
<li><a href='#' id='part-edit'><span class='fas fa-edit icon-blue'></span> {% trans "Edit part" %}</a></li>
{% endif %}
{% if not part.active and roles.part.delete %}
<li><a href='#' id='part-delete'><span class='fas fa-trash-alt icon-red'></span> {% trans "Delete part" %}</a></li>
{% endif %}
</ul>
</div>
{% endif %}
<table class='table table-condensed'>
<col width='25'>
{% if part.IPN %}
<tr>
<td></td>
<td>{% trans "IPN" %}</td>
<td>{{ part.IPN }}</td>
</tr>
{% endif %}
{% if part.link %}
<tr>
<td><span class='fas fa-link'></span></td>
<td>{% trans "External Link" %}</td>
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
</tr>
{% endif %}
<tr>
</tr>
</table>
</div>
<table class='table table-condensed'>
</div>
</div>
<div class="col-sm-6">
<table class="table table-striped">
<col width='25'>
{% if part.IPN %}
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>
<h4>{% trans "Available Stock" %}</h4>
</td>
<td><h4>{% decimal available %}{% if part.units %} {{ part.units }}{% endif %}</h4></td>
</tr>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "In Stock" %}</td>
<td>{% include "part/stock_count.html" %}</td>
</tr>
{% if on_order > 0 %}
<tr>
<td><span class='fas fa-shopping-cart'></span></td>
<td>{% trans "On Order" %}</td>
<td>{% decimal on_order %}</td>
</tr>
{% endif %}
{% if required_build_order_quantity > 0 %}
<tr>
<td><span class='fas fa-clipboard-list'></span></td>
<td>{% trans "Required for Build Orders" %}</td>
<td>{% decimal required_build_order_quantity %}
</tr>
{% endif %}
{% if required_sales_order_quantity > 0 %}
<tr>
<td><span class='fas fa-clipboard-list'></span></td>
<td>{% trans "Required for Sales Orders" %}</td>
<td>{% decimal required_sales_order_quantity %}
</tr>
{% endif %}
{% if allocated > 0 %}
<tr>
<td><span class='fas fa-dolly'></span></td>
<td>{% trans "Allocated to Orders" %}</td>
<td>{% decimal allocated %}</td>
</tr>
{% endif %}
{% if not part.is_template %}
{% if part.assembly %}
<tr>
<td><span class='fas fa-tools'></span></td>
<td colspan='2'>
<b>{% trans "Build Status" %}</b>
</td>
</tr>
<tr>
<td></td>
<td>{% trans "IPN" %}</td>
<td>{{ part.IPN }}</td>
<td>{% trans "Can Build" %}</td>
<td>{% decimal part.can_build %}</td>
</tr>
{% if quantity_being_built > 0 %}
<tr>
<td></td>
<td>{% trans "Building" %}</td>
<td>{% decimal quantity_being_built %}</td>
</tr>
{% endif %}
{% if part.link %}
<tr>
<td><span class='fas fa-link'></span></td>
<td>{% trans "External Link" %}</td>
<td><a href="{{ part.link }}">{{ part.link }}</a></td>
</tr>
{% endif %}
<tr>
</tr>
{% endif %}
</table>
</div>
</div>
</div>
<div class="col-sm-6">
<table class="table table-striped">
<col width='25'>
<tr>
<td><span class='fas fa-boxes'></span></td>
<td>
<h4>{% trans "Available Stock" %}</h4>
</td>
<td><h4>{% decimal available %}{% if part.units %} {{ part.units }}{% endif %}</h4></td>
</tr>
<tr>
<td><span class='fas fa-map-marker-alt'></span></td>
<td>{% trans "In Stock" %}</td>
<td>{% include "part/stock_count.html" %}</td>
</tr>
{% if on_order > 0 %}
<tr>
<td><span class='fas fa-shopping-cart'></span></td>
<td>{% trans "On Order" %}</td>
<td>{% decimal on_order %}</td>
</tr>
{% endif %}
{% if required_build_order_quantity > 0 %}
<tr>
<td><span class='fas fa-clipboard-list'></span></td>
<td>{% trans "Required for Build Orders" %}</td>
<td>{% decimal required_build_order_quantity %}
</tr>
{% endif %}
{% if required_sales_order_quantity > 0 %}
<tr>
<td><span class='fas fa-clipboard-list'></span></td>
<td>{% trans "Required for Sales Orders" %}</td>
<td>{% decimal required_sales_order_quantity %}
</tr>
{% endif %}
{% if allocated > 0 %}
<tr>
<td><span class='fas fa-dolly'></span></td>
<td>{% trans "Allocated to Orders" %}</td>
<td>{% decimal allocated %}</td>
</tr>
{% endif %}
{% if not part.is_template %}
{% if part.assembly %}
<tr>
<td><span class='fas fa-tools'></span></td>
<td colspan='2'>
<b>{% trans "Build Status" %}</b>
</td>
</tr>
<tr>
<td></td>
<td>{% trans "Can Build" %}</td>
<td>{% decimal part.can_build %}</td>
</tr>
{% if quantity_being_built > 0 %}
<tr>
<td></td>
<td>{% trans "Building" %}</td>
<td>{% decimal quantity_being_built %}</td>
</tr>
{% endif %}
{% endif %}
{% endif %}
</table>
</div>
</div>
<hr>
<div class='container-fluid'>
{% block details %}
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>
{% block heading %}
<!-- Heading goes here -->
{% endblock %}
</h4>
</div>
<!-- Specific part details go here... -->
{% endblock %}
<div class='panel-content'>
{% block details %}
<!-- Specific part details go here... -->
{% endblock %}
</div>
</div>
{% endblock %}
@ -195,6 +201,11 @@
{% block js_ready %}
{{ block.super }}
enableNavbar({
label: 'part',
toggleId: '#part-menu-toggle',
});
enableDragAndDrop(
'#part-thumb',
"{% url 'part-image-upload' part.id %}",

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='tests' %}
{% endblock %}
{% block heading %}
{% trans "Part Test Templates" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='tests' %}
<h4>{% trans "Part Test Templates" %}</h4>
<hr>
<div id='button-toolbar'>
<div class='button-toolbar container-fluid' style="float: right;">
<div class='btn-group' role='group'>

View File

@ -2,13 +2,16 @@
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='related' %}
{% endblock %}
{% block heading %}
{% trans "Related Parts" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='related-parts' %}
<h4>{% trans "Related Parts" %}</h4>
<hr>
<div id='button-bar'>
<div class='button-toolbar container-fluid' style='float: left;'>
{% if roles.part.change %}

View File

@ -2,13 +2,16 @@
{% load static %}
{% load i18n %}
{% block menubar %}}
{% include 'part/navbar.html' with tab='sales-prices' %}
{% endblock %}
{% block heading %}
{% trans "Sell Price Information" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='sales-prices' %}
<h4>{% trans "Sale Price" %}</h4>
<hr>
<div id='price-break-toolbar' class='btn-group'>
<button class='btn btn-primary' id='new-price-break' type='button'>
<span class='fas fa-plus-circle'></span> {% trans "Add Price Break" %}

View File

@ -2,13 +2,16 @@
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='sales-orders' %}
{% endblock %}
{% block heading %}
{% trans "Sales Orders" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='sales-orders' %}
<h4>{% trans "Sales Orders" %}</h4>
<hr>
<div id='button-bar'>
<div class='button-toolbar container-fluid' style='float: right;'>
{% if 0 %}

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='stock' %}
{% endblock %}
{% block heading %}
{% trans "Part Stock" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='stock' %}
<h4>{% trans "Part Stock" %}</h4>
<hr>
{% if part.is_template %}
<div class='alert alert-info alert-block'>
Showing stock for all variants of <i>{{ part.full_name }}</i>

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='suppliers' %}
{% endblock %}
{% block heading %}
{% trans "Part Suppliers" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='suppliers' %}
<h4>{% trans "Part Suppliers" %}</h4>
<hr>
<div id='button-toolbar'>
<div class='btn-group'>
<button class="btn btn-success" id='supplier-create'>

View File

@ -1,73 +0,0 @@
{% load i18n %}
{% load inventree_extras %}
<ul class="nav nav-tabs">
<li{% ifequal tab 'detail' %} class="active"{% endifequal %}>
<a href="{% url 'part-detail' part.id %}">{% trans "Details" %}</a>
</li>
<li{% ifequal tab 'params' %} class='active'{% endifequal %}>
<a href="{% url 'part-params' part.id %}">{% trans "Parameters" %}<span class='badge'>{{ part.parameters.count }}</span></a>
</li>
{% if part.is_template %}
<li{% ifequal tab 'variants' %} class='active'{% endifequal %}>
<a href="{% url 'part-variants' part.id %}">{% trans "Variants" %} <span class='badge'>{{ part.variants.count }}</span></span></a>
</li>
{% endif %}
<li{% ifequal tab 'stock' %} class="active"{% endifequal %}>
<a href="{% url 'part-stock' part.id %}">{% trans "Stock" %} <span class="badge">{% decimal total_stock %}</span></a>
</li>
{% if part.component or part.salable or part.used_in_count > 0 %}
<li{% ifequal tab 'allocation' %} class="active"{% endifequal %}>
<a href="{% url 'part-allocation' part.id %}">{% trans "Allocated" %} <span class="badge">{% decimal allocated %}</span></a>
</li>
{% endif %}
{% if part.assembly %}
<li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
<a href="{% url 'part-bom' part.id %}">{% trans "BOM" %}<span class="badge{% if part.is_bom_valid == False %} badge-alert{% endif %}">{{ part.bom_count }}</span></a></li>
{% if roles.build.view %}
<li{% ifequal tab 'build' %} class="active"{% endifequal %}>
<a href="{% url 'part-build' part.id %}">{% trans "Build Orders" %}<span class='badge'>{{ part.builds.count }}</span></a>
</li>
{% endif %}
{% endif %}
{% if part.component or part.used_in_count > 0 %}
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
<a href="{% url 'part-used-in' part.id %}">{% trans "Used In" %} {% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
{% endif %}
{% if part.purchaseable and roles.purchase_order.view %}
{% if part.is_template == False %}
<li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
<a href="{% url 'part-suppliers' part.id %}">{% trans "Suppliers" %}
<span class="badge">{{ part.supplier_count }}</span>
</a>
</li>
{% endif %}
<li{% ifequal tab 'orders' %} class='active'{% endifequal %}>
<a href="{% url 'part-orders' part.id %}">{% trans "Purchase Orders" %} <span class='badge'>{{ part.purchase_orders|length }}</span></a>
</li>
{% endif %}
{% if part.salable and roles.sales_order.view %}
<li {% if tab == 'sales-prices' %}class='active'{% endif %}>
<a href="{% url 'part-sale-prices' part.id %}">{% trans "Sale Price" %}</a>
</li>
<li{% ifequal tab 'sales-orders' %} class='active'{% endifequal %}>
<a href="{% url 'part-sales-orders' part.id %}">{% trans "Sales Orders" %} <span class='badge'>{{ part.sales_orders|length }}</span></a>
</li>
{% endif %}
{% if part.trackable %}
<li{% ifequal tab 'tests' %} class='active'{% endifequal %}>
<a href='{% url "part-test-templates" part.id %}'>{% trans "Tests" %}
{% if part.getTestTemplates.count > 0 %}<span class='badge'>{{ part.getTestTemplates.count }}</span>{% endif %}
</a>
</li>
{% endif %}
<li{% ifequal tab 'related-parts' %} class="active"{% endifequal %}>
<a href="{% url 'part-related' part.id %}">{% trans "Related" %} {% if part.related_count > 0 %}<span class="badge">{{ part.related_count }}</span>{% endif %}</a>
</li>
<li{% ifequal tab 'attachments' %} class="active"{% endifequal %}>
<a href="{% url 'part-attachments' part.id %}">{% trans "Attachments" %} {% if part.attachment_count > 0 %}<span class="badge">{{ part.attachment_count }}</span>{% endif %}</a>
</li>
<li{% ifequal tab 'notes' %} class="active"{% endifequal %}>
<a href="{% url 'part-notes' part.id %}">{% trans "Notes" %}{% if part.notes %} <span class='fas fa-info-circle'></span>{% endif %}</a>
</li>
</ul>

View File

@ -1,12 +1,14 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='track' %}
{% endblock %}
{% block heading %}
{% trans "Part Tracking" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='track' %}
<h4>{% trans "Part Tracking" %}</h4>
<hr>
{% endblock %}

View File

@ -1,13 +1,16 @@
{% extends "part/part_base.html" %}
{% load i18n %}
{% block menubar %}
{% include 'part/navbar.html' with tab='used' %}
{% endblock %}
{% block heading %}
{% trans "Assemblies" %}
{% endblock %}
{% block details %}
{% include 'part/tabs.html' with tab='used' %}
<h4>{% trans "Assemblies" %}</h4>
<hr>
<div id='button-toolbar'>
<div class='filter-list' id='filter-list-usedin'>
<!-- Empty div (will be filled out with avilable BOM filters) -->

View File

@ -3,18 +3,15 @@
{% load i18n %}
{% load inventree_extras %}
{% block menubar %}
{% include "part/navbar.html" with tab='variants' %}
{% endblock %}
{% block heading %}
{% trans "Part Variants" %}
{% endblock %}
{% block details %}
{% include "part/tabs.html" with tab='variants' %}
<div class='row'>
<div class='col-sm-6'>
<h4>{% trans "Part Variants" %}</h4>
</div>
<div class='col-sm-6'>
</div>
</div>
<hr>
<div id='button-toolbar'>
<div class='button-toolbar container-fluid'>
<div class='btn-group' role='group'>

View File

@ -753,14 +753,15 @@ class PartNotes(UpdateView):
part = self.get_object()
ctx = super().get_context_data(**kwargs)
context = super().get_context_data(**kwargs)
ctx['editing'] = str2bool(self.request.GET.get('edit', ''))
context['editing'] = str2bool(self.request.GET.get('edit', ''))
ctx['starred'] = part.isStarredBy(self.request.user)
ctx['disabled'] = not part.active
ctx = part.get_context_data(self.request)
return ctx
context.update(ctx)
return context
class PartDetail(InvenTreeRoleMixin, DetailView):
@ -779,7 +780,7 @@ class PartDetail(InvenTreeRoleMixin, DetailView):
- If '?editing=True', set 'editing_enabled' context variable
"""
context = super(PartDetail, self).get_context_data(**kwargs)
context = super().get_context_data(**kwargs)
part = self.get_object()
@ -789,24 +790,8 @@ class PartDetail(InvenTreeRoleMixin, DetailView):
else:
context['editing_enabled'] = 0
context['starred'] = part.isStarredBy(self.request.user)
context['disabled'] = not part.active
# Pre-calculate complex queries so they only need to be performed once
context['total_stock'] = part.total_stock
context['quantity_being_built'] = part.quantity_being_built
context['required_build_order_quantity'] = part.required_build_order_quantity()
context['allocated_build_order_quantity'] = part.build_order_allocation_count()
context['required_sales_order_quantity'] = part.required_sales_order_quantity()
context['allocated_sales_order_quantity'] = part.sales_order_allocation_count()
context['available'] = part.available_stock
context['on_order'] = part.on_order
context['required'] = context['required_build_order_quantity'] + context['required_sales_order_quantity']
context['allocated'] = context['allocated_build_order_quantity'] + context['allocated_sales_order_quantity']
ctx = part.get_context_data(self.request)
context.update(**ctx)
return context