mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 05:48:47 +00:00
Enable printing for PO and SO
This commit is contained in:
parent
7800664f4b
commit
fa95759a00
@ -35,7 +35,10 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
<hr>
|
<hr>
|
||||||
<p>{{ order.description }}</p>
|
<p>{{ order.description }}</p>
|
||||||
<div class='btn-row'>
|
<div class='btn-row'>
|
||||||
<div class='btn-group action-buttons'>
|
<div class='btn-group action-buttons' role='group'>
|
||||||
|
<button type='button' class='btn btn-default' id='print-order-report' title='{% trans "Print" %}'>
|
||||||
|
<span class='fas fa-print'></span>
|
||||||
|
</button>
|
||||||
{% if roles.purchase_order.change %}
|
{% if roles.purchase_order.change %}
|
||||||
<button type='button' class='btn btn-default' id='edit-order' title='{% trans "Edit order information" %}'>
|
<button type='button' class='btn btn-default' id='edit-order' title='{% trans "Edit order information" %}'>
|
||||||
<span class='fas fa-edit icon-green'></span>
|
<span class='fas fa-edit icon-green'></span>
|
||||||
@ -149,6 +152,10 @@ $("#place-order").click(function() {
|
|||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
$('#print-order-report').click(function() {
|
||||||
|
printPurchaseOrderReports([{{ order.pk }}]);
|
||||||
|
});
|
||||||
|
|
||||||
$("#edit-order").click(function() {
|
$("#edit-order").click(function() {
|
||||||
launchModalForm("{% url 'po-edit' order.id %}",
|
launchModalForm("{% url 'po-edit' order.id %}",
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,9 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
<p>{{ order.description }}</p>
|
<p>{{ order.description }}</p>
|
||||||
<div class='btn-row'>
|
<div class='btn-row'>
|
||||||
<div class='btn-group action-buttons'>
|
<div class='btn-group action-buttons'>
|
||||||
|
<button type='button' class='btn btn-default' id='print-order-report' title='{% trans "Print" %}'>
|
||||||
|
<span class='fas fa-print'></span>
|
||||||
|
</button>
|
||||||
{% if roles.sales_order.change %}
|
{% if roles.sales_order.change %}
|
||||||
<button type='button' class='btn btn-default' id='edit-order' title='Edit order information'>
|
<button type='button' class='btn btn-default' id='edit-order' title='Edit order information'>
|
||||||
<span class='fas fa-edit icon-green'></span>
|
<span class='fas fa-edit icon-green'></span>
|
||||||
@ -158,4 +161,8 @@ $("#ship-order").click(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#print-order-report').click(function() {
|
||||||
|
printSalesOrderReports([{{ order.pk }}]);
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -555,8 +555,8 @@ class POReportList(ReportListView, OrderReportMixin):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for order in orders:
|
for o in orders:
|
||||||
order_query = order.models.PurchaseOrder.objects.filter(pk=order.pk)
|
order_query = order.models.PurchaseOrder.objects.filter(pk=o.pk)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not order_query.filter(**filters).exists():
|
if not order_query.filter(**filters).exists():
|
||||||
@ -638,8 +638,8 @@ class SOReportList(ReportListView, OrderReportMixin):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for order in orders:
|
for o in orders:
|
||||||
order_query = order.models.SalesOrder.objects.filter(pk=order.pk)
|
order_query = order.models.SalesOrder.objects.filter(pk=o.pk)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not order_query.filter(**filters).exists():
|
if not order_query.filter(**filters).exists():
|
||||||
|
@ -247,3 +247,111 @@ function printBomReports(parts, options={}) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function printPurchaseOrderReports(orders, options={}) {
|
||||||
|
/**
|
||||||
|
* Print PO reports for the provided purchase order(s)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (orders.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Select Purchase Orders" %}',
|
||||||
|
'{% trans "Purchase Order(s) must be selected before printing report" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request avaiable report templates
|
||||||
|
inventreeGet(
|
||||||
|
'{% url "api-po-report-list" %}',
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
orders: orders,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
if (response.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "No Reports Found" %}',
|
||||||
|
'{% trans "No report templates found which match selected orders" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select report template
|
||||||
|
selectReport(
|
||||||
|
response,
|
||||||
|
orders,
|
||||||
|
{
|
||||||
|
success: function(pk) {
|
||||||
|
var href = `/api/report/po/${pk}/print/?`;
|
||||||
|
|
||||||
|
orders.forEach(function(order) {
|
||||||
|
href += `order=${order}&`;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function printSalesOrderReports(orders, options={}) {
|
||||||
|
/**
|
||||||
|
* Print SO reports for the provided purchase order(s)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (orders.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Select Sales Orders" %}',
|
||||||
|
'{% trans "Sales Order(s) must be selected before printing report" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request avaiable report templates
|
||||||
|
inventreeGet(
|
||||||
|
'{% url "api-so-report-list" %}',
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
orders: orders,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
if (response.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "No Reports Found" %}',
|
||||||
|
'{% trans "No report templates found which match selected orders" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select report template
|
||||||
|
selectReport(
|
||||||
|
response,
|
||||||
|
orders,
|
||||||
|
{
|
||||||
|
success: function(pk) {
|
||||||
|
var href = `/api/report/so/${pk}/print/?`;
|
||||||
|
|
||||||
|
orders.forEach(function(order) {
|
||||||
|
href += `order=${order}&`;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user