Skip to content

Commit

Permalink
Shipment Reports (#8194)
Browse files Browse the repository at this point in the history
* Shipment Reports

* bump api version due to changed enums

---------

Co-authored-by: Matthias Mair <[email protected]>
  • Loading branch information
fuzeman and matmair authored Oct 1, 2024
1 parent 96a2517 commit fe7bbc2
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/docs/report/samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following report templates are provided "out of the box" and can be used as
| [Purchase Order](#purchase-order) | [PurchaseOrder](../order/purchase_order.md) | Purchase Order report |
| [Return Order](#return-order) | [ReturnOrder](../order/return_order.md) | Return Order report |
| [Sales Order](#sales-order) | [SalesOrder](../order/sales_order.md) | Sales Order report |
| [Sales Order Shipment](#sales-order-shipment) | [SalesOrderShipment](../order/sales_order.md) | Sales Order Shipment report |
| [Stock Location](#stock-location) | [StockLocation](../stock/stock.md#stock-location) | Stock Location report |
| [Test Report](#test-report) | [StockItem](../stock/stock.md#stock-item) | Test Report |

Expand All @@ -42,6 +43,10 @@ The following report templates are provided "out of the box" and can be used as

{{ templatefile("report/inventree_sales_order_report.html") }}

### Sales Order Shipment

{{ templatefile("report/inventree_sales_order_shipment_report.html") }}

### Stock Location

{{ templatefile("report/inventree_stock_location_report.html") }}
Expand Down
5 changes: 4 additions & 1 deletion src/backend/InvenTree/InvenTree/api_version.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""InvenTree API version information."""

# InvenTree API version
INVENTREE_API_VERSION = 262
INVENTREE_API_VERSION = 263

"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""


INVENTREE_API_TEXT = """
263 - 2024-09-30 : https://github.com/inventree/InvenTree/pull/8194
- Adds Sales Order Shipment report
262 - 2024-09-30 : https://github.com/inventree/InvenTree/pull/8220
- Tweak permission requirements for uninstalling plugins via API
Expand Down
12 changes: 12 additions & 0 deletions src/backend/InvenTree/order/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ def is_completed(self):

class SalesOrderShipment(
InvenTree.models.InvenTreeNotesMixin,
report.mixins.InvenTreeReportMixin,
InvenTree.models.MetadataMixin,
InvenTree.models.InvenTreeModel,
):
Expand Down Expand Up @@ -1768,6 +1769,17 @@ def get_api_url():
"""Return the API URL associated with the SalesOrderShipment model."""
return reverse('api-so-shipment-list')

def report_context(self):
"""Generate context data for the reporting interface."""
return {
'allocations': self.allocations,
'order': self.order,
'reference': self.reference,
'shipment': self,
'tracking_number': self.tracking_number,
'title': str(self),
}

order = models.ForeignKey(
SalesOrder,
on_delete=models.CASCADE,
Expand Down
7 changes: 7 additions & 0 deletions src/backend/InvenTree/report/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ def create_default_reports(self):
'model_type': 'salesorder',
'filename_pattern': 'SalesOrder-{{ reference }}.pdf',
},
{
'file': 'inventree_sales_order_shipment_report.html',
'name': 'InvenTree Sales Order Shipment',
'description': 'Sample sales order shipment report',
'model_type': 'salesordershipment',
'filename_pattern': 'SalesOrderShipment-{{ reference }}.pdf',
},
{
'file': 'inventree_return_order_report.html',
'name': 'InvenTree Return Order',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% extends "report/inventree_order_report_base.html" %}

{% load i18n %}
{% load report %}
{% load barcode %}
{% load inventree_extras %}
{% load markdownify %}

{% block header_content %}

<img class='logo' src='{% company_image order.customer %}' alt="{{ order.customer }}" width='150'>

<div class='header-right'>
<h3>{% trans "Shipment" %} {{ prefix }}{{ reference }}</h3>
<i>{% trans "Sales Order" %} {{ order.reference }}</i><br/>
{{ order.customer.name }}
</div>

{% endblock header_content %}

{% block page_content %}

<h3>{% trans "Allocations" %}</h3>

<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Part" %}</th>
<th>{% trans "Stock Item" %}</th>
</tr>
</thead>
<tbody>
{% for allocation in allocations.all %}
<tr>
<td>
<div class='thumb-container'>
<img src='{% part_image allocation.line.part height=240 %}' alt='{% trans "Part image" %}' class='part-thumb'>
</div>
<div class='part-text'>
{{ allocation.line.part.full_name }}
</div>
</td>

{% if allocation.item and allocation.item.serial and allocation.quantity == 1 %}
<td>{% trans "Serial Number" %}: {{ allocation.item.serial }}</td>
{% elif allocation.item and allocation.item.batch %}
<td>{% trans "Quantity" %}: {% decimal allocation.quantity %} - <i>{% trans "Batch" %}: {{ allocation.item.batch }}</i></td>
{% else %}
<td>{% trans "Quantity" %}: {% decimal allocation.quantity %}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>

{% endblock page_content %}
9 changes: 7 additions & 2 deletions src/backend/InvenTree/templates/js/translated/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,11 @@ function loadSalesOrderShipmentTable(table, options={}) {

var filters = loadTableFilters('salesordershipment', options.params);

setupFilterList('salesordershipment', $(table), options.filter_target);
setupFilterList('salesordershipment', $(table), options.filter_target, {
report: {
key: 'salesordershipment',
}
});

// Add callbacks for expand / collapse buttons
var prefix = options.shipped ? 'completed' : 'pending';
Expand Down Expand Up @@ -1018,8 +1022,9 @@ function loadSalesOrderShipmentTable(table, options={}) {
},
columns: [
{
visible: false,
title: '',
checkbox: true,
visible: true,
switchable: false,
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/src/tables/sales/SalesOrderShipmentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from 'react';

import { AddItemButton } from '../../components/buttons/AddItemButton';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles';
import { useSalesOrderShipmentFields } from '../../forms/SalesOrderForms';
import { notYetImplemented } from '../../functions/notifications';
Expand Down Expand Up @@ -167,6 +168,9 @@ export default function SalesOrderShipmentTable({
props={{
tableActions: tableActions,
tableFilters: tableFilters,
modelType: ModelType.salesordershipment,
enableSelection: true,
enableReports: true,
rowActions: rowActions,
params: {
order: orderId
Expand Down

0 comments on commit fe7bbc2

Please sign in to comment.