Skip to content

Commit

Permalink
PO shipped complete (#7367)
Browse files Browse the repository at this point in the history
* Add new setting to bypass "shipped" status

* Bypass "shipped" status optionally

* Update setting description string

* Update unit tests

* Refactor location of status_codes

* Link source code into docs

* Add stock status codes

* And the build order too

* Fix import
  • Loading branch information
SchrodingersGat authored May 30, 2024
1 parent fb193ca commit 798c0ed
Show file tree
Hide file tree
Showing 48 changed files with 440 additions and 272 deletions.
12 changes: 12 additions & 0 deletions docs/docs/build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ Each *Build Order* has an associated *Status* flag, which indicates the state of
| `Cancelled` | Build has been cancelled |
| `Completed` | Build has been completed |

**Source Code**

Refer to the source code for the Build Order status codes:

::: build.status_codes.BuildStatus
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

### Stock Allocations

When a *Build Order* is created, we then have the ability to *allocate* stock items against that build order. The particular parts we need to allocate against the build are specified by the BOM for the part we are assembling.
Expand Down
14 changes: 14 additions & 0 deletions docs/docs/order/purchase_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ Each Purchase Order has a specific status code which indicates the current state
| In Progress | The purchase order has been issued to the supplier, and is in progress |
| Complete | The purchase order has been completed, and is now closed |
| Cancelled | The purchase order was cancelled, and is now closed |
| Lost | The purchase order was lost, and is now closed |
| Returned | The purchase order was returned, and is now closed |

**Source Code**

Refer to the source code for the Purchase Order status codes:

::: order.status_codes.PurchaseOrderStatus
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

### Purchase Order Currency

Expand Down
12 changes: 12 additions & 0 deletions docs/docs/order/return_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ Each Return Order has a specific status code, as follows:
| Complete | The return order was marked as complete, and is now closed |
| Cancelled | The return order was cancelled, and is now closed |

**Source Code**

Refer to the source code for the Return Order status codes:

::: order.status_codes.ReturnOrderStatus
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

## Create a Return Order

From the Return Order index, click on <span class='badge inventree add'><span class='fas fa-plus-circle'></span> New Return Order</span> which opens the "Create Return Order" form.
Expand Down
19 changes: 17 additions & 2 deletions docs/docs/order/sales_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@ Each Sales Order has a specific status code, which represents the state of the o
| --- | --- |
| Pending | The sales order has been created, but has not been finalized or submitted |
| In Progress | The sales order has been issued, and is in progress |
| Shipped | The sales order has been completed, and is now closed |
| Shipped | The sales order has been shipped, but is not yet complete |
| Complete | The sales order is fully completed, and is now closed |
| Cancelled | The sales order was cancelled, and is now closed |
| Lost | The sales order was lost, and is now closed |
| Returned | The sales order was returned, and is now closed |

**Source Code**

Refer to the source code for the Sales Order status codes:

::: order.status_codes.SalesOrderStatus
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

### Sales Order Currency

Expand Down Expand Up @@ -83,7 +98,7 @@ To view all the completed shipment, click on the <span class="badge inventree na

### Complete Order

Once all items in the sales order have been shipped, click on <span class="badge inventree add"><span class='fas fa-check-circle'></span> Complete Order</span> to mark the sales order as complete.
Once all items in the sales order have been shipped, click on <span class="badge inventree add"><span class='fas fa-check-circle'></span> Complete Order</span> to mark the sales order as shipped. Confirm then click on <span class="badge inventree confirm">Submit</span> to complete the order.

### Cancel Order

Expand Down
12 changes: 12 additions & 0 deletions docs/docs/stock/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ The *status* of a given stock item is displayed on the stock item detail page:
{% include 'img.html' %}
{% endwith %}

**Source Code**

Refer to the source code for the Stock status codes:

::: stock.status_codes.StockStatus
options:
show_bases: False
show_root_heading: False
show_root_toc_entry: False
show_source: True
members: []

### Default Status Code

The default status code for any newly created Stock Item is <span class='badge inventree success'>OK</span>
Expand Down
203 changes: 7 additions & 196 deletions src/backend/InvenTree/InvenTree/status_codes.py
Original file line number Diff line number Diff line change
@@ -1,198 +1,9 @@
"""Status codes for InvenTree."""
"""Global import of all status codes.
from django.utils.translation import gettext_lazy as _
This file remains here for backwards compatibility,
as external plugins may import status codes from this file.
"""

from generic.states import StatusCode


class PurchaseOrderStatus(StatusCode):
"""Defines a set of status codes for a PurchaseOrder."""

# Order status codes
PENDING = 10, _('Pending'), 'secondary' # Order is pending (not yet placed)
PLACED = 20, _('Placed'), 'primary' # Order has been placed with supplier
COMPLETE = 30, _('Complete'), 'success' # Order has been completed
CANCELLED = 40, _('Cancelled'), 'danger' # Order was cancelled
LOST = 50, _('Lost'), 'warning' # Order was lost
RETURNED = 60, _('Returned'), 'warning' # Order was returned


class PurchaseOrderStatusGroups:
"""Groups for PurchaseOrderStatus codes."""

# Open orders
OPEN = [PurchaseOrderStatus.PENDING.value, PurchaseOrderStatus.PLACED.value]

# Failed orders
FAILED = [
PurchaseOrderStatus.CANCELLED.value,
PurchaseOrderStatus.LOST.value,
PurchaseOrderStatus.RETURNED.value,
]


class SalesOrderStatus(StatusCode):
"""Defines a set of status codes for a SalesOrder."""

PENDING = 10, _('Pending'), 'secondary' # Order is pending
IN_PROGRESS = (
15,
_('In Progress'),
'primary',
) # Order has been issued, and is in progress
SHIPPED = 20, _('Shipped'), 'success' # Order has been shipped to customer
COMPLETE = 30, _('Complete'), 'success' # Order is complete
CANCELLED = 40, _('Cancelled'), 'danger' # Order has been cancelled
LOST = 50, _('Lost'), 'warning' # Order was lost
RETURNED = 60, _('Returned'), 'warning' # Order was returned


class SalesOrderStatusGroups:
"""Groups for SalesOrderStatus codes."""

# Open orders
OPEN = [SalesOrderStatus.PENDING.value, SalesOrderStatus.IN_PROGRESS.value]

# Completed orders
COMPLETE = [SalesOrderStatus.SHIPPED.value, SalesOrderStatus.COMPLETE.value]


class StockStatus(StatusCode):
"""Status codes for Stock."""

OK = 10, _('OK'), 'success' # Item is OK
ATTENTION = 50, _('Attention needed'), 'warning' # Item requires attention
DAMAGED = 55, _('Damaged'), 'warning' # Item is damaged
DESTROYED = 60, _('Destroyed'), 'danger' # Item is destroyed
REJECTED = 65, _('Rejected'), 'danger' # Item is rejected
LOST = 70, _('Lost'), 'dark' # Item has been lost
QUARANTINED = (
75,
_('Quarantined'),
'info',
) # Item has been quarantined and is unavailable
RETURNED = 85, _('Returned'), 'warning' # Item has been returned from a customer


class StockStatusGroups:
"""Groups for StockStatus codes."""

# The following codes correspond to parts that are 'available' or 'in stock'
AVAILABLE_CODES = [
StockStatus.OK.value,
StockStatus.ATTENTION.value,
StockStatus.DAMAGED.value,
StockStatus.RETURNED.value,
]


class StockHistoryCode(StatusCode):
"""Status codes for StockHistory."""

LEGACY = 0, _('Legacy stock tracking entry')

CREATED = 1, _('Stock item created')

# Manual editing operations
EDITED = 5, _('Edited stock item')
ASSIGNED_SERIAL = 6, _('Assigned serial number')

# Manual stock operations
STOCK_COUNT = 10, _('Stock counted')
STOCK_ADD = 11, _('Stock manually added')
STOCK_REMOVE = 12, _('Stock manually removed')

# Location operations
STOCK_MOVE = 20, _('Location changed')
STOCK_UPDATE = 25, _('Stock updated')

# Installation operations
INSTALLED_INTO_ASSEMBLY = 30, _('Installed into assembly')
REMOVED_FROM_ASSEMBLY = 31, _('Removed from assembly')

INSTALLED_CHILD_ITEM = 35, _('Installed component item')
REMOVED_CHILD_ITEM = 36, _('Removed component item')

# Stock splitting operations
SPLIT_FROM_PARENT = 40, _('Split from parent item')
SPLIT_CHILD_ITEM = 42, _('Split child item')

# Stock merging operations
MERGED_STOCK_ITEMS = 45, _('Merged stock items')

# Convert stock item to variant
CONVERTED_TO_VARIANT = 48, _('Converted to variant')

# Build order codes
BUILD_OUTPUT_CREATED = 50, _('Build order output created')
BUILD_OUTPUT_COMPLETED = 55, _('Build order output completed')
BUILD_OUTPUT_REJECTED = 56, _('Build order output rejected')
BUILD_CONSUMED = 57, _('Consumed by build order')

# Sales order codes
SHIPPED_AGAINST_SALES_ORDER = 60, _('Shipped against Sales Order')

# Purchase order codes
RECEIVED_AGAINST_PURCHASE_ORDER = 70, _('Received against Purchase Order')

# Return order codes
RETURNED_AGAINST_RETURN_ORDER = 80, _('Returned against Return Order')

# Customer actions
SENT_TO_CUSTOMER = 100, _('Sent to customer')
RETURNED_FROM_CUSTOMER = 105, _('Returned from customer')


class BuildStatus(StatusCode):
"""Build status codes."""

PENDING = 10, _('Pending'), 'secondary' # Build is pending / active
PRODUCTION = 20, _('Production'), 'primary' # BuildOrder is in production
CANCELLED = 30, _('Cancelled'), 'danger' # Build was cancelled
COMPLETE = 40, _('Complete'), 'success' # Build is complete


class BuildStatusGroups:
"""Groups for BuildStatus codes."""

ACTIVE_CODES = [BuildStatus.PENDING.value, BuildStatus.PRODUCTION.value]


class ReturnOrderStatus(StatusCode):
"""Defines a set of status codes for a ReturnOrder."""

# Order is pending, waiting for receipt of items
PENDING = 10, _('Pending'), 'secondary'

# Items have been received, and are being inspected
IN_PROGRESS = 20, _('In Progress'), 'primary'

COMPLETE = 30, _('Complete'), 'success'
CANCELLED = 40, _('Cancelled'), 'danger'


class ReturnOrderStatusGroups:
"""Groups for ReturnOrderStatus codes."""

OPEN = [ReturnOrderStatus.PENDING.value, ReturnOrderStatus.IN_PROGRESS.value]


class ReturnOrderLineStatus(StatusCode):
"""Defines a set of status codes for a ReturnOrderLineItem."""

PENDING = 10, _('Pending'), 'secondary'

# Item is to be returned to customer, no other action
RETURN = 20, _('Return'), 'success'

# Item is to be repaired, and returned to customer
REPAIR = 30, _('Repair'), 'primary'

# Item is to be replaced (new item shipped)
REPLACE = 40, _('Replace'), 'warning'

# Item is to be refunded (cannot be repaired)
REFUND = 50, _('Refund'), 'info'

# Item is rejected
REJECT = 60, _('Reject'), 'danger'
from build.status_codes import *
from order.status_codes import *
from stock.status_codes import *
2 changes: 1 addition & 1 deletion src/backend/InvenTree/build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from InvenTree.api import AttachmentMixin, APIDownloadMixin, ListCreateDestroyAPIView, MetadataView
from generic.states.api import StatusView
from InvenTree.helpers import str2bool, isNull, DownloadFile
from InvenTree.status_codes import BuildStatus, BuildStatusGroups
from build.status_codes import BuildStatus, BuildStatusGroups
from InvenTree.mixins import CreateAPI, RetrieveUpdateDestroyAPI, ListCreateAPI

import common.models
Expand Down
3 changes: 2 additions & 1 deletion src/backend/InvenTree/build/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

from rest_framework import serializers

from InvenTree.status_codes import BuildStatus, StockStatus, StockHistoryCode, BuildStatusGroups
from build.status_codes import BuildStatus, BuildStatusGroups
from stock.status_codes import StockStatus, StockHistoryCode

from build.validators import generate_next_build_reference, validate_build_order_reference

Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/build/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import InvenTree.helpers
from InvenTree.serializers import InvenTreeDecimalField
from InvenTree.status_codes import StockStatus
from stock.status_codes import StockStatus

from stock.generators import generate_batch_code
from stock.models import StockItem, StockLocation
Expand Down
20 changes: 20 additions & 0 deletions src/backend/InvenTree/build/status_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Build status codes."""

from django.utils.translation import gettext_lazy as _

from generic.states import StatusCode


class BuildStatus(StatusCode):
"""Build status codes."""

PENDING = 10, _('Pending'), 'secondary' # Build is pending / active
PRODUCTION = 20, _('Production'), 'primary' # BuildOrder is in production
CANCELLED = 30, _('Cancelled'), 'danger' # Build was cancelled
COMPLETE = 40, _('Complete'), 'success' # Build is complete


class BuildStatusGroups:
"""Groups for BuildStatus codes."""

ACTIVE_CODES = [BuildStatus.PENDING.value, BuildStatus.PRODUCTION.value]
2 changes: 1 addition & 1 deletion src/backend/InvenTree/build/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import InvenTree.helpers
import InvenTree.helpers_model
import InvenTree.tasks
from InvenTree.status_codes import BuildStatusGroups
from InvenTree.ready import isImportingData
from build.status_codes import BuildStatusGroups

import part.models as part_models

Expand Down
3 changes: 2 additions & 1 deletion src/backend/InvenTree/build/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from build.models import Build, BuildItem
from stock.models import StockItem

from InvenTree.status_codes import BuildStatus, StockStatus
from build.status_codes import BuildStatus
from stock.status_codes import StockStatus
from InvenTree.unit_test import InvenTreeAPITestCase


Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/build/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .models import Build
from stock.models import StockItem

from InvenTree.status_codes import BuildStatus
from build.status_codes import BuildStatus


class BuildTestSimple(InvenTreeTestCase):
Expand Down
Loading

0 comments on commit 798c0ed

Please sign in to comment.