Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2020-10-19 22:19:43 +11:00
commit 4604d7c90d
13 changed files with 94 additions and 26 deletions

View File

@ -354,7 +354,7 @@ function renderErrorMessage(xhr) {
var html = '<b>' + xhr.statusText + '</b><br>'; var html = '<b>' + xhr.statusText + '</b><br>';
html += '<b>Status Code - ' + xhr.status + '</b><br><hr>'; html += '<b>Error Code - ' + xhr.status + '</b><br><hr>';
html += ` html += `
<div class='panel-group'> <div class='panel-group'>
@ -811,16 +811,37 @@ function launchModalForm(url, options = {}) {
$(modal).modal('hide'); $(modal).modal('hide');
// Permission denied! // Permission denied!
if (xhr.status == 403) { if (xhr.status == 400) {
showAlertDialog( showAlertDialog(
"Permission Denied", "Error 400: Bad Request",
"Server returned error code 400"
);
} else if (xhr.status == 401) {
showAlertDialog(
"Error 401: Not Authenticated",
"Authentication credentials not supplied"
);
} else if (xhr.status == 403) {
showAlertDialog(
"Error 403: Permission Denied",
"You do not have the required permissions to access this function" "You do not have the required permissions to access this function"
); );
} else if (xhr.status == 404) {
return; showAlertDialog(
"Error 404: Resource Not Found",
"The requested resource could not be located on the server"
);
} else if (xhr.status == 408) {
showAlertDialog(
"Error 408: Timeout",
"Connection timeout while requesting data from server"
);
} else {
showAlertDialog('Error requesting form data', renderErrorMessage(xhr));
} }
showAlertDialog('Error requesting form data', renderErrorMessage(xhr)); console.log("Modal form error: " + xhr.status);
console.log("Message: " + xhr.responseText);
} }
}; };

View File

@ -423,12 +423,16 @@ class SupplierPart(models.Model):
return str(self) return str(self)
def __str__(self): def __str__(self):
s = "{supplier} ({sku})".format( s = ''
sku=self.SKU,
supplier=self.supplier.name) if self.part.IPN:
s += f'{self.part.IPN}'
s += ' | '
s += f'{self.supplier.name} | {self.SKU}'
if self.manufacturer_string: if self.manufacturer_string:
s = s + ' - ' + self.manufacturer_string s = s + ' | ' + self.manufacturer_string
return s return s

View File

@ -94,7 +94,7 @@ src="{% static 'img/blank_image.png' %}"
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}
$('#order-part').click(function() { $('#order-part, #order-part2').click(function() {
launchModalForm( launchModalForm(
"{% url 'order-parts' %}", "{% url 'order-parts' %}",
{ {

View File

@ -6,13 +6,13 @@
{% include "company/supplier_part_tabs.html" with tab='orders' %} {% include "company/supplier_part_tabs.html" with tab='orders' %}
<hr>
<h4>{% trans "Supplier Part Orders" %}</h4> <h4>{% trans "Supplier Part Orders" %}</h4>
<hr>
<div id='button-bar'> <div id='button-bar'>
<div class='btn-group'> <div class='btn-group'>
<button class='btn btn-primary' type='button' id='part-order2' title='Order part'>Order Part</button> <button class='btn btn-primary' type='button' id='order-part2' title='Order part'>Order Part</button>
</div> </div>
</div> </div>

View File

@ -7,10 +7,10 @@
{% include "company/supplier_part_tabs.html" with tab='pricing' %} {% include "company/supplier_part_tabs.html" with tab='pricing' %}
<hr>
<h4>{% trans "Pricing Information" %}</h4> <h4>{% trans "Pricing Information" %}</h4>
<hr>
<div id='price-break-toolbar' class='btn-group'> <div id='price-break-toolbar' class='btn-group'>
<button class='btn btn-primary' id='new-price-break' type='button'>{% trans "Add Price Break" %}</button> <button class='btn btn-primary' id='new-price-break' type='button'>{% trans "Add Price Break" %}</button>
</div> </div>

View File

@ -6,10 +6,10 @@
{% include "company/supplier_part_tabs.html" with tab='stock' %} {% include "company/supplier_part_tabs.html" with tab='stock' %}
<hr>
<h4>{% trans "Supplier Part Stock" %}</h4> <h4>{% trans "Supplier Part Stock" %}</h4>
<hr>
{% include "stock_table.html" %} {% include "stock_table.html" %}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,34 @@
{% extends "order/order_base.html" %}
{% load inventree_extras %}
{% load i18n %}
{% load static %}
{% block details %}
{% include 'order/po_tabs.html' with tab='received' %}
<h4>{% trans "Received Items" %}</h4>
<hr>
{% include "stock_table.html" with read_only=True %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
loadStockTable($("#stock-table"), {
params: {
purchase_order: {{ order.id }},
part_detail: true,
supplier_detail: true,
location_detail: true,
},
buttons: [
'#stock-options',
],
filterkey: "postock"
});
{% endblock %}

View File

@ -2,7 +2,10 @@
<ul class='nav nav-tabs'> <ul class='nav nav-tabs'>
<li{% ifequal tab 'details' %} class='active'{% endifequal %}> <li{% ifequal tab 'details' %} class='active'{% endifequal %}>
<a href="{% url 'po-detail' order.id %}">{% trans "Items" %}</a> <a href="{% url 'po-detail' order.id %}">{% trans "Line Items" %}</a>
</li>
<li {% if tab == 'received' %} class='active'{% endif %}>
<a href="{% url 'po-received' order.id %}">{% trans "Received Items" %}</a>
</li> </li>
<li{% if tab == 'attachments' %} class='active'{% endif %}> <li{% if tab == 'attachments' %} class='active'{% endif %}>
<a href="{% url 'po-attachments' order.id %}">{% trans "Attachments" %} <a href="{% url 'po-attachments' order.id %}">{% trans "Attachments" %}

View File

@ -13,7 +13,7 @@
<div id='order-toolbar-buttons' class='btn-group' style='float: right;'> <div id='order-toolbar-buttons' class='btn-group' style='float: right;'>
{% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %} {% if order.status == PurchaseOrderStatus.PENDING and roles.purchase_order.change %}
<button type='button' class='btn btn-default' id='new-po-line'>{% trans "Add Line Item" %}</button> <button type='button' class='btn btn-primary' id='new-po-line'>{% trans "Add Line Item" %}</button>
{% endif %} {% endif %}
</div> </div>

View File

@ -21,6 +21,7 @@ purchase_order_detail_urls = [
url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'), url(r'^notes/', views.PurchaseOrderNotes.as_view(), name='po-notes'),
url(r'^received/', views.PurchaseOrderDetail.as_view(template_name='order/po_received_items.html'), name='po-received'),
url(r'^attachments/', views.PurchaseOrderDetail.as_view(template_name='order/po_attachments.html'), name='po-attachments'), url(r'^attachments/', views.PurchaseOrderDetail.as_view(template_name='order/po_attachments.html'), name='po-attachments'),
url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='po-detail'), url(r'^.*$', views.PurchaseOrderDetail.as_view(), name='po-detail'),
] ]

View File

@ -498,6 +498,11 @@ class StockList(generics.ListCreateAPIView):
if sales_order: if sales_order:
queryset = queryset.filter(sales_order=sales_order) queryset = queryset.filter(sales_order=sales_order)
purchase_order = params.get('purchase_order', None)
if purchase_order is not None:
queryset = queryset.filter(purchase_order=purchase_order)
# Filter stock items which are installed in another (specific) stock item # Filter stock items which are installed in another (specific) stock item
installed_in = params.get('installed_in', None) installed_in = params.get('installed_in', None)

View File

@ -228,7 +228,7 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% if item.uid %} {% if item.uid %}
<tr> <tr>
<td><span class='fas fa-barcode'></span></td> <td><span class='fas fa-barcode'></span></td>
<td>{% trans "Unique Identifier" %}</td> <td>{% trans "Barcode Identifier" %}</td>
<td>{{ item.uid }}</td> <td>{{ item.uid }}</td>
</tr> </tr>
{% endif %} {% endif %}

View File

@ -262,7 +262,7 @@ function loadStockTable(table, options) {
formatNoMatches: function() { formatNoMatches: function() {
return '{% trans "No stock items matching query" %}'; return '{% trans "No stock items matching query" %}';
}, },
url: options.url, url: options.url || "{% url 'api-stock-list' %}",
queryParams: filters, queryParams: filters,
customSort: customGroupSorter, customSort: customGroupSorter,
groupBy: true, groupBy: true,