Coverage for src/backend/InvenTree/stock/status_codes.py: 100%
42 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""Stock status codes."""
3from django.utils.translation import gettext_lazy as _
5from generic.states import ColorEnum, StatusCode
8class StockStatus(StatusCode):
9 """Status codes for Stock."""
11 OK = 10, _('OK'), ColorEnum.success # Item is OK
12 ATTENTION = 50, _('Attention needed'), ColorEnum.warning # Item requires attention
13 DAMAGED = 55, _('Damaged'), ColorEnum.warning # Item is damaged
14 DESTROYED = 60, _('Destroyed'), ColorEnum.danger # Item is destroyed
15 REJECTED = 65, _('Rejected'), ColorEnum.danger # Item is rejected
16 LOST = 70, _('Lost'), ColorEnum.dark # Item has been lost
17 QUARANTINED = (
18 75,
19 _('Quarantined'),
20 ColorEnum.info,
21 ) # Item has been quarantined and is unavailable
22 RETURNED = (
23 85,
24 _('Returned'),
25 ColorEnum.warning,
26 ) # Item has been returned from a customer
29class StockStatusGroups:
30 """Groups for StockStatus codes."""
32 # The following codes correspond to parts that are 'available' or 'in stock'
33 AVAILABLE_CODES = [
34 StockStatus.OK.value,
35 StockStatus.ATTENTION.value,
36 StockStatus.DAMAGED.value,
37 StockStatus.RETURNED.value,
38 ]
41class StockHistoryCode(StatusCode):
42 """Status codes for StockHistory."""
44 LEGACY = 0, _('Legacy stock tracking entry')
46 CREATED = 1, _('Stock item created')
48 # Manual editing operations
49 EDITED = 5, _('Edited stock item')
50 ASSIGNED_SERIAL = 6, _('Assigned serial number')
52 # Manual stock operations
53 STOCK_COUNT = 10, _('Stock counted')
54 STOCK_ADD = 11, _('Stock manually added')
55 STOCK_REMOVE = 12, _('Stock manually removed')
56 STOCK_SERIALIZED = 13, _('Serialized stock items')
58 RETURNED_TO_STOCK = 15, _('Returned to stock') # Stock item returned to stock
60 # Location operations
61 STOCK_MOVE = 20, _('Location changed')
62 STOCK_UPDATE = 25, _('Stock updated')
64 # Installation operations
65 INSTALLED_INTO_ASSEMBLY = 30, _('Installed into assembly')
66 REMOVED_FROM_ASSEMBLY = 31, _('Removed from assembly')
68 INSTALLED_CHILD_ITEM = 35, _('Installed component item')
69 REMOVED_CHILD_ITEM = 36, _('Removed component item')
71 # Stock splitting operations
72 SPLIT_FROM_PARENT = 40, _('Split from parent item')
73 SPLIT_CHILD_ITEM = 42, _('Split child item')
75 # Stock merging operations
76 MERGED_STOCK_ITEMS = 45, _('Merged stock items')
78 # Convert stock item to variant
79 CONVERTED_TO_VARIANT = 48, _('Converted to variant')
81 # Build order codes
82 BUILD_OUTPUT_CREATED = 50, _('Build order output created')
83 BUILD_OUTPUT_COMPLETED = 55, _('Build order output completed')
84 BUILD_OUTPUT_REJECTED = 56, _('Build order output rejected')
85 BUILD_CONSUMED = 57, _('Consumed by build order')
87 # Sales order codes
88 SHIPPED_AGAINST_SALES_ORDER = 60, _('Shipped against Sales Order')
90 # Purchase order codes
91 RECEIVED_AGAINST_PURCHASE_ORDER = 70, _('Received against Purchase Order')
93 # Return order codes
94 RETURNED_AGAINST_RETURN_ORDER = 80, _('Returned against Return Order')
96 # Customer actions
97 SENT_TO_CUSTOMER = 100, _('Sent to customer')
98 RETURNED_FROM_CUSTOMER = 105, _('Returned from customer')