mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
Adds basic "index" page for Return Order model
This commit is contained in:
@ -10,7 +10,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<li class='breadcrumb-item'><a href='{% url "po-index" %}'>{% trans "Purchase Orders" %}</a></li>
|
<li class='breadcrumb-item'><a href='{% url "purchase-order-index" %}'>{% trans "Purchase Orders" %}</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "po-detail" order.id %}'>{{ order }}</a></li>
|
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "po-detail" order.id %}'>{{ order }}</a></li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
65
InvenTree/order/templates/order/return_orders.html
Normal file
65
InvenTree/order/templates/order/return_orders.html
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{% extends "page_base.html" %}
|
||||||
|
|
||||||
|
{% load inventree_extras %}
|
||||||
|
{% load static %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block page_title %}
|
||||||
|
{% inventree_title %} | {% trans "Return Orders" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumb_list %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block heading %}
|
||||||
|
{% trans "Return Orders" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block actions %}
|
||||||
|
{% if roles.returns.add %}
|
||||||
|
<button class='btn btn-success' type='button' id='return-order-create' title='{% trans "Create new return order" %}'>
|
||||||
|
<span class='fas fa-plus-circle'></span> {% trans "New Return Order" %}
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock actions %}
|
||||||
|
|
||||||
|
{% block page_info %}
|
||||||
|
|
||||||
|
<div class='panel-content'>
|
||||||
|
<div id='table-buttons'>
|
||||||
|
<div class='button-toolbar container-fluid' style='float: right;'>
|
||||||
|
<div class='btn-group'>
|
||||||
|
{% if report_enabled %}
|
||||||
|
<button id='order-print' class='btn btn-outline-secondary' title='{% trans "Print Order Reports" %}'>
|
||||||
|
<span class='fas fa-print'></span>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% include "filter_list.html" with id="returnorder" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-striped table-condensed' data-toolbar='#table-buttons' id='return-order-table'>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div id='return-order-calendar'></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock page_info %}
|
||||||
|
|
||||||
|
{% block js_ready %}
|
||||||
|
{{ block.super }}
|
||||||
|
|
||||||
|
loadReturnOrderTable('#return-order-table', {
|
||||||
|
});
|
||||||
|
|
||||||
|
{% if report_enabled %}
|
||||||
|
<!-- TODO: report button callbacks -->
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
$('#return-order-create').click(function() {
|
||||||
|
createReturnOrder();
|
||||||
|
});
|
||||||
|
|
||||||
|
{% endblock js_ready %}
|
@ -10,7 +10,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
<li class='breadcrumb-item'><a href='{% url "so-index" %}'>{% trans "Sales Orders" %}</a></li>
|
<li class='breadcrumb-item'><a href='{% url "sales-order-index" %}'>{% trans "Sales Orders" %}</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "so-detail" order.id %}'>{{ order }}</a></li>
|
<li class="breadcrumb-item active" aria-current="page"><a href='{% url "so-detail" order.id %}'>{{ order }}</a></li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class OrderListTest(OrderViewTestCase):
|
|||||||
"""Unit tests for the PurchaseOrder index page"""
|
"""Unit tests for the PurchaseOrder index page"""
|
||||||
def test_order_list(self):
|
def test_order_list(self):
|
||||||
"""Tests for the PurchaseOrder index page"""
|
"""Tests for the PurchaseOrder index page"""
|
||||||
response = self.client.get(reverse('po-index'))
|
response = self.client.get(reverse('purchase-order-index'))
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ purchase_order_urls = [
|
|||||||
re_path(r'^(?P<pk>\d+)/', include(purchase_order_detail_urls)),
|
re_path(r'^(?P<pk>\d+)/', include(purchase_order_detail_urls)),
|
||||||
|
|
||||||
# Display complete list of purchase orders
|
# Display complete list of purchase orders
|
||||||
re_path(r'^.*$', views.PurchaseOrderIndex.as_view(), name='po-index'),
|
re_path(r'^.*$', views.PurchaseOrderIndex.as_view(), name='purchase-order-index'),
|
||||||
]
|
]
|
||||||
|
|
||||||
sales_order_detail_urls = [
|
sales_order_detail_urls = [
|
||||||
@ -38,10 +38,19 @@ sales_order_urls = [
|
|||||||
re_path(r'^(?P<pk>\d+)/', include(sales_order_detail_urls)),
|
re_path(r'^(?P<pk>\d+)/', include(sales_order_detail_urls)),
|
||||||
|
|
||||||
# Display list of all sales orders
|
# Display list of all sales orders
|
||||||
re_path(r'^.*$', views.SalesOrderIndex.as_view(), name='so-index'),
|
re_path(r'^.*$', views.SalesOrderIndex.as_view(), name='sales-order-index'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
return_order_urls = [
|
||||||
|
|
||||||
|
# Display list of all return orders
|
||||||
|
re_path(r'^.*$', views.ReturnOrderIndex.as_view(), name='return-order-index'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
order_urls = [
|
order_urls = [
|
||||||
re_path(r'^purchase-order/', include(purchase_order_urls)),
|
re_path(r'^purchase-order/', include(purchase_order_urls)),
|
||||||
re_path(r'^sales-order/', include(sales_order_urls)),
|
re_path(r'^sales-order/', include(sales_order_urls)),
|
||||||
|
re_path(r'^return-order/', include(return_order_urls)),
|
||||||
]
|
]
|
||||||
|
@ -24,8 +24,8 @@ from plugin.views import InvenTreePluginViewMixin
|
|||||||
|
|
||||||
from . import forms as order_forms
|
from . import forms as order_forms
|
||||||
from .admin import PurchaseOrderLineItemResource, SalesOrderLineItemResource
|
from .admin import PurchaseOrderLineItemResource, SalesOrderLineItemResource
|
||||||
from .models import (PurchaseOrder, PurchaseOrderLineItem, SalesOrder,
|
from .models import (PurchaseOrder, PurchaseOrderLineItem, ReturnOrder,
|
||||||
SalesOrderLineItem)
|
SalesOrder, SalesOrderLineItem)
|
||||||
|
|
||||||
logger = logging.getLogger("inventree")
|
logger = logging.getLogger("inventree")
|
||||||
|
|
||||||
@ -51,6 +51,14 @@ class SalesOrderIndex(InvenTreeRoleMixin, ListView):
|
|||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
|
|
||||||
|
|
||||||
|
class ReturnOrderIndex(InvenTreeRoleMixin, ListView):
|
||||||
|
"""ReturnOrder index (list) view"""
|
||||||
|
|
||||||
|
model = ReturnOrder
|
||||||
|
template_name = 'order/return_orders.html'
|
||||||
|
context_object_name = 'orders'
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrderDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
class PurchaseOrderDetail(InvenTreeRoleMixin, InvenTreePluginViewMixin, DetailView):
|
||||||
"""Detail view for a PurchaseOrder object."""
|
"""Detail view for a PurchaseOrder object."""
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
completePendingShipments,
|
completePendingShipments,
|
||||||
createPurchaseOrder,
|
createPurchaseOrder,
|
||||||
createPurchaseOrderLineItem,
|
createPurchaseOrderLineItem,
|
||||||
|
createReturnOrder,
|
||||||
createSalesOrder,
|
createSalesOrder,
|
||||||
createSalesOrderLineItem,
|
createSalesOrderLineItem,
|
||||||
createSalesOrderShipment,
|
createSalesOrderShipment,
|
||||||
@ -41,6 +42,7 @@
|
|||||||
loadPurchaseOrderLineItemTable,
|
loadPurchaseOrderLineItemTable,
|
||||||
loadPurchaseOrderExtraLineTable
|
loadPurchaseOrderExtraLineTable
|
||||||
loadPurchaseOrderTable,
|
loadPurchaseOrderTable,
|
||||||
|
loadReturnOrderTable,
|
||||||
loadSalesOrderAllocationTable,
|
loadSalesOrderAllocationTable,
|
||||||
loadSalesOrderLineItemTable,
|
loadSalesOrderLineItemTable,
|
||||||
loadSalesOrderExtraLineTable
|
loadSalesOrderExtraLineTable
|
||||||
@ -536,9 +538,7 @@ function salesOrderFields(options={}) {
|
|||||||
title: '{% trans "Add Customer" %}',
|
title: '{% trans "Add Customer" %}',
|
||||||
fields: function() {
|
fields: function() {
|
||||||
var fields = companyFormFields();
|
var fields = companyFormFields();
|
||||||
|
|
||||||
fields.is_customer.value = true;
|
fields.is_customer.value = true;
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,10 +573,10 @@ function createSalesOrder(options={}) {
|
|||||||
constructForm('{% url "api-so-list" %}', {
|
constructForm('{% url "api-so-list" %}', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
fields: fields,
|
fields: fields,
|
||||||
|
title: '{% trans "Create Sales Order" %}',
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
location.href = `/order/sales-order/${data.pk}/`;
|
location.href = `/order/sales-order/${data.pk}/`;
|
||||||
},
|
},
|
||||||
title: '{% trans "Create Sales Order" %}',
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4662,3 +4662,163 @@ function loadSalesOrderExtraLineTable(table, options={}) {
|
|||||||
columns: columns,
|
columns: columns,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct a set of fields for a ReturnOrder form
|
||||||
|
*/
|
||||||
|
function returnOrderFields(options={}) {
|
||||||
|
|
||||||
|
let fields = {
|
||||||
|
reference: {
|
||||||
|
icon: 'fa-hashtag',
|
||||||
|
},
|
||||||
|
description: {},
|
||||||
|
customer: {
|
||||||
|
icon: 'fa-user-tie',
|
||||||
|
secondary: {
|
||||||
|
title: '{% trans "Add Customer" %}',
|
||||||
|
fields: function() {
|
||||||
|
var fields = companyFormFields();
|
||||||
|
fields.is_customer.value = true;
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
customer_reference: {},
|
||||||
|
link: {
|
||||||
|
icon: 'fa-link',
|
||||||
|
},
|
||||||
|
responsible: {
|
||||||
|
icon: 'fa-user',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a new Return Order
|
||||||
|
*/
|
||||||
|
function createReturnOrder(options={}) {
|
||||||
|
let fields = returnOrderFields(options);
|
||||||
|
|
||||||
|
if (options.customer) {
|
||||||
|
fields.customer.value = options.customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructForm('{% url "api-return-order-list" %}', {
|
||||||
|
method: 'POST',
|
||||||
|
fields: fields,
|
||||||
|
title: '{% trans "Create Return Order" %}',
|
||||||
|
onSuccess: function(data) {
|
||||||
|
location.href = `/order/return-order/${data.pk}/`;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load a table of return orders
|
||||||
|
*/
|
||||||
|
function loadReturnOrderTable(table, options={}) {
|
||||||
|
|
||||||
|
// Ensure the table starts in a known state
|
||||||
|
$(table).bootstrapTable('destroy');
|
||||||
|
|
||||||
|
options.params = options.params || {};
|
||||||
|
options.params['customer_detail'] = true;
|
||||||
|
|
||||||
|
var filters = loadTableFilters('returnorder');
|
||||||
|
|
||||||
|
for (var key in options.params) {
|
||||||
|
filters[key] = options.params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFilterList('returnorder', $(table), '#filter-list-returnorder', {download: true});
|
||||||
|
|
||||||
|
let display_mode = inventreeLoad('returnorder-table-display-mode', 'list');
|
||||||
|
|
||||||
|
let is_calendar = display_mode == 'calendar';
|
||||||
|
|
||||||
|
$(table).inventreeTable({
|
||||||
|
url: '{% url "api-return-order-list" %}',
|
||||||
|
queryParams: filters,
|
||||||
|
name: 'returnorder',
|
||||||
|
sidePagination: 'server',
|
||||||
|
original: options.params,
|
||||||
|
showColumns: !is_calendar,
|
||||||
|
search: !is_calendar,
|
||||||
|
showCustomViewButton: false,
|
||||||
|
showCustomView: is_calendar,
|
||||||
|
disablePagination: is_calendar,
|
||||||
|
formatNoMatches: function() {
|
||||||
|
return '{% trans "No return orders found" %}';
|
||||||
|
},
|
||||||
|
onRefresh: function() {
|
||||||
|
loadReturnOrderTable(table, options);
|
||||||
|
},
|
||||||
|
onLoadSuccess: function() {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: '',
|
||||||
|
checkbox: true,
|
||||||
|
visible: true,
|
||||||
|
switchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
field: 'reference',
|
||||||
|
title: '{% trans "Return Order" %}',
|
||||||
|
formatter: function(value, row) {
|
||||||
|
var html = renderLink(value, `/order/return-order/${row.pk}/`);
|
||||||
|
return html;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
sortName: 'customer__name',
|
||||||
|
field: 'customer_detail',
|
||||||
|
title: '{% trans "Customer" %}',
|
||||||
|
formatter: function(value, row) {
|
||||||
|
|
||||||
|
if (!row.customer_detail) {
|
||||||
|
return '{% trans "Invalid Customer" %}';
|
||||||
|
}
|
||||||
|
|
||||||
|
return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
field: 'customer_reference',
|
||||||
|
title: '{% trans "Customer Reference" %}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: false,
|
||||||
|
field: 'description',
|
||||||
|
title: '{% trans "Description" %}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
field: 'status',
|
||||||
|
title: '{% trans "Status" %}',
|
||||||
|
formatter: function(value, row) {
|
||||||
|
return 'todo';
|
||||||
|
return salesOrderStatusDisplay(row.status);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sortable: true,
|
||||||
|
field: 'creation_date',
|
||||||
|
title: '{% trans "Creation Date" %}',
|
||||||
|
formatter: function(value) {
|
||||||
|
return renderDate(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -47,18 +47,23 @@
|
|||||||
<ul class='dropdown-menu' aria-labelledby="buyMenuDropdown">
|
<ul class='dropdown-menu' aria-labelledby="buyMenuDropdown">
|
||||||
<li><a class='dropdown-item' href="{% url 'supplier-index' %}"><span class='fas fa-building icon-header'></span>{% trans "Suppliers" %}</a></li>
|
<li><a class='dropdown-item' href="{% url 'supplier-index' %}"><span class='fas fa-building icon-header'></span>{% trans "Suppliers" %}</a></li>
|
||||||
<li><a class='dropdown-item' href="{% url 'manufacturer-index' %}"><span class='fas fa-industry icon-header'></span>{% trans "Manufacturers" %}</a></li>
|
<li><a class='dropdown-item' href="{% url 'manufacturer-index' %}"><span class='fas fa-industry icon-header'></span>{% trans "Manufacturers" %}</a></li>
|
||||||
<li><a class='dropdown-item' href="{% url 'po-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Purchase Orders" %}</a></li>
|
<li><a class='dropdown-item' href="{% url 'purchase-order-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Purchase Orders" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if roles.sales_order.view %}
|
{% if roles.sales_order.view or roles.returns.view %}
|
||||||
<li class='nav-item dropdown'>
|
<li class='nav-item dropdown'>
|
||||||
<a class='nav-link dropdown-toggle' href='#' id='sellMenuDropdown' role='button' data-bs-toggle='dropdown'>
|
<a class='nav-link dropdown-toggle' href='#' id='sellMenuDropdown' role='button' data-bs-toggle='dropdown'>
|
||||||
<span class='fas fa-truck icon-header'></span>{% trans "Sell" %}
|
<span class='fas fa-truck icon-header'></span>{% trans "Sell" %}
|
||||||
</a>
|
</a>
|
||||||
<ul class='dropdown-menu'>
|
<ul class='dropdown-menu'>
|
||||||
<li><a class='dropdown-item' href="{% url 'customer-index' %}"><span class='fas fa-user-tie icon-header'></span>{% trans "Customers" %}</a>
|
<li><a class='dropdown-item' href="{% url 'customer-index' %}"><span class='fas fa-user-tie icon-header'></span>{% trans "Customers" %}</a>
|
||||||
<li><a class='dropdown-item' href="{% url 'so-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Sales Orders" %}</a></li>
|
{% if roles.sales_order.view %}
|
||||||
|
<li><a class='dropdown-item' href="{% url 'sales-order-index' %}"><span class='fas fa-list icon-header'></span>{% trans "Sales Orders" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if roles.returns.view %}
|
||||||
|
<li><a class='dropdown-item' href="{% url 'return-order-index' %}"><span class='fas fa-undo icon-header'></span>{% trans "Returns" %}</a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user