mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Shipment Reports (#8194)
* Shipment Reports * bump api version due to changed enums --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
		@@ -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 |
 | 
					| [Purchase Order](#purchase-order) | [PurchaseOrder](../order/purchase_order.md) | Purchase Order report |
 | 
				
			||||||
| [Return Order](#return-order) | [ReturnOrder](../order/return_order.md) | Return 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](#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 |
 | 
					| [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 |
 | 
					| [Test Report](#test-report) | [StockItem](../stock/stock.md#stock-item) | Test Report |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -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") }}
 | 
					{{ templatefile("report/inventree_sales_order_report.html") }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Sales Order Shipment
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{{ templatefile("report/inventree_sales_order_shipment_report.html") }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Stock Location
 | 
					### Stock Location
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{ templatefile("report/inventree_stock_location_report.html") }}
 | 
					{{ templatefile("report/inventree_stock_location_report.html") }}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,16 @@
 | 
				
			|||||||
"""InvenTree API version information."""
 | 
					"""InvenTree API version information."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# InvenTree API version
 | 
					# 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."""
 | 
					"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INVENTREE_API_TEXT = """
 | 
					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
 | 
					262 - 2024-09-30 : https://github.com/inventree/InvenTree/pull/8220
 | 
				
			||||||
    - Tweak permission requirements for uninstalling plugins via API
 | 
					    - Tweak permission requirements for uninstalling plugins via API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1739,6 +1739,7 @@ class SalesOrderLineItem(OrderLineItem):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class SalesOrderShipment(
 | 
					class SalesOrderShipment(
 | 
				
			||||||
    InvenTree.models.InvenTreeNotesMixin,
 | 
					    InvenTree.models.InvenTreeNotesMixin,
 | 
				
			||||||
 | 
					    report.mixins.InvenTreeReportMixin,
 | 
				
			||||||
    InvenTree.models.MetadataMixin,
 | 
					    InvenTree.models.MetadataMixin,
 | 
				
			||||||
    InvenTree.models.InvenTreeModel,
 | 
					    InvenTree.models.InvenTreeModel,
 | 
				
			||||||
):
 | 
					):
 | 
				
			||||||
@@ -1768,6 +1769,17 @@ class SalesOrderShipment(
 | 
				
			|||||||
        """Return the API URL associated with the SalesOrderShipment model."""
 | 
					        """Return the API URL associated with the SalesOrderShipment model."""
 | 
				
			||||||
        return reverse('api-so-shipment-list')
 | 
					        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(
 | 
					    order = models.ForeignKey(
 | 
				
			||||||
        SalesOrder,
 | 
					        SalesOrder,
 | 
				
			||||||
        on_delete=models.CASCADE,
 | 
					        on_delete=models.CASCADE,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -173,6 +173,13 @@ class ReportConfig(AppConfig):
 | 
				
			|||||||
                'model_type': 'salesorder',
 | 
					                'model_type': 'salesorder',
 | 
				
			||||||
                'filename_pattern': 'SalesOrder-{{ reference }}.pdf',
 | 
					                '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',
 | 
					                'file': 'inventree_return_order_report.html',
 | 
				
			||||||
                'name': 'InvenTree Return Order',
 | 
					                'name': 'InvenTree Return Order',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 %}
 | 
				
			||||||
@@ -919,7 +919,11 @@ function loadSalesOrderShipmentTable(table, options={}) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var filters = loadTableFilters('salesordershipment', options.params);
 | 
					    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
 | 
					    // Add callbacks for expand / collapse buttons
 | 
				
			||||||
    var prefix = options.shipped ? 'completed' : 'pending';
 | 
					    var prefix = options.shipped ? 'completed' : 'pending';
 | 
				
			||||||
@@ -1018,8 +1022,9 @@ function loadSalesOrderShipmentTable(table, options={}) {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        columns: [
 | 
					        columns: [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                visible: false,
 | 
					                title: '',
 | 
				
			||||||
                checkbox: true,
 | 
					                checkbox: true,
 | 
				
			||||||
 | 
					                visible: true,
 | 
				
			||||||
                switchable: false,
 | 
					                switchable: false,
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from 'react';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { AddItemButton } from '../../components/buttons/AddItemButton';
 | 
					import { AddItemButton } from '../../components/buttons/AddItemButton';
 | 
				
			||||||
import { ApiEndpoints } from '../../enums/ApiEndpoints';
 | 
					import { ApiEndpoints } from '../../enums/ApiEndpoints';
 | 
				
			||||||
 | 
					import { ModelType } from '../../enums/ModelType';
 | 
				
			||||||
import { UserRoles } from '../../enums/Roles';
 | 
					import { UserRoles } from '../../enums/Roles';
 | 
				
			||||||
import { useSalesOrderShipmentFields } from '../../forms/SalesOrderForms';
 | 
					import { useSalesOrderShipmentFields } from '../../forms/SalesOrderForms';
 | 
				
			||||||
import { notYetImplemented } from '../../functions/notifications';
 | 
					import { notYetImplemented } from '../../functions/notifications';
 | 
				
			||||||
@@ -167,6 +168,9 @@ export default function SalesOrderShipmentTable({
 | 
				
			|||||||
        props={{
 | 
					        props={{
 | 
				
			||||||
          tableActions: tableActions,
 | 
					          tableActions: tableActions,
 | 
				
			||||||
          tableFilters: tableFilters,
 | 
					          tableFilters: tableFilters,
 | 
				
			||||||
 | 
					          modelType: ModelType.salesordershipment,
 | 
				
			||||||
 | 
					          enableSelection: true,
 | 
				
			||||||
 | 
					          enableReports: true,
 | 
				
			||||||
          rowActions: rowActions,
 | 
					          rowActions: rowActions,
 | 
				
			||||||
          params: {
 | 
					          params: {
 | 
				
			||||||
            order: orderId
 | 
					            order: orderId
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user