FAQ
How is raw material added to the system?
Raw materials are added to the system through the ReceivedMaterial
model. When a vendor delivers materials, the following process occurs:
- A new
ReceivedMaterial
record is created with: - Vendor information
- Material reference
- Quantity (units)
- Purchase order number
- Shipping information (carrier, bill of lading)
- Receipt date
-
Batch/lot number (auto-generated if not provided)
-
When a
ReceivedMaterial
record is saved: - The system validates that quantity is positive and receipt date is not in the future
- An automatic
MaterialInventory
record is created or updated for the material - The
rcvd
field inMaterialInventory
is updated to reflect the new quantity - A
MaterialTransaction
is implicitly created showing movement of material to the RAW stage
The system tracks all received materials with their metadata, allowing for batch traceability from vendor to final product.
How is raw material allocated?
Raw materials are allocated through the MaterialTransaction
model. The process moves materials from the RAW stage to the ALLOCATED stage:
- When materials are assigned to a specific production order, a
MaterialTransaction
record is created with: - Material reference
- From_stage = "RAW"
- To_stage = "ALLOCATED"
-
Quantity needed for the production run
-
This allocation reduces the available quantity in the RAW stage while increasing the amount in the ALLOCATED stage, as tracked by:
- The
quantity_in_stage()
method in theMaterial
model - Corresponding fields in the
MaterialInventory
model
This allocation mechanism reserves materials for specific production batches without physically removing them from inventory, ensuring materials are not double-counted or over-allocated.
How do we track batched material?
Batched materials are tracked through multiple models:
BatchTicket
model:- Links to a specific
OrderItem
- Contains manufacturing details (EPA numbers, quantities, temperatures)
- Automatically generates a unique lot number (format: CP[YY][DayOfYear][BatchLetter])
-
Tracks the total quantity of materials used in a batch
-
BatchMaterial
model: - Links to a
BatchTicket
- Records each specific component used in the batch
- Stores each component's lot number, manufacturer, description, etc.
-
Tracks planned weight versus actual weight used
-
MaterialTransaction
records track the movement: - From ALLOCATED stage to BATCHED stage
- Records the specific quantity used in production
The system maintains complete batch traceability by connecting raw materials to finished goods through the batch ticket system.
How do we track materials and components that have been assigned to an assembly line?
Materials assigned to assembly lines are tracked through the MPSRecord
(Master Production Schedule) and associated models:
- The
MPSRecord
model: - Links to a specific
OrderItem
(which contains product and quantity information) - Assigns production to a specific
Line
- Schedules production during a specific
Shift
- Tracks start and end dates
-
Monitors production status (Scheduled, Running, Delayed, Completed)
-
The
ProductionRecord
model: - Tracks actual production against an MPSRecord
- Records quantity produced
- Timestamps when production occurred
-
Relates back to the line and order item through the MPSRecord
-
MaterialTransaction
records track movement of components: - From BATCHED stage to other stages as assembly progresses
This system provides visibility into: - Which materials are at which assembly line - Production progress compared to schedule - Remaining quantity to be produced - Expected completion dates
How finished/assembled material move to shipped?
Finished materials move to shipped through the following flow:
- When production is complete on an assembly line, the system:
- Updates the status of the
MPSRecord
to "Completed" -
Creates a
MaterialTransaction
record moving materials from FINISHED to SHIPPED stage -
The
MaterialTransaction
model records: - Material reference
- From_stage = "FINISHED"
- To_stage = "SHIPPED"
-
Quantity being shipped
-
The
Order
model: - Tracks the overall order status (Open, Closed, Cancelled)
- May be updated to "Closed" when all items are shipped
- Records the closed date
This flow ensures accurate tracking of inventory throughout the entire lifecycle, from receipt to shipment.
How does material go from running to finished?
Materials transition from running to finished status through:
- The
ProductionRecord
model: - Records actual quantities produced against an
MPSRecord
-
Each record represents completed units of production
-
When production is complete:
- The
MPSRecord
status is updated from "Running" to "Completed" - The
percent_complete
property reaches 100% -
A
MaterialTransaction
record is created moving materials from BATCHED (or intermediate stages) to FINISHED -
The system calculates:
- Total produced quantity via
total_produced_quantity
property - Remaining quantity via
remaining_quantity
property - Completion percentage via
percent_complete
property
This transition represents the point where materials have completed the production process and are ready for shipping.
How do we determine quantity on hand for raw materials, components, batched materials, packaged/finished materials, and shipped materials?
Quantities are determined through several mechanisms:
- For raw materials:
- The
MaterialInventory.qoh
property calculates: beginning balance + received - batched - adjustments -
The
Material.raw
property callsquantity_in_stage(InventoryStages.RAW)
-
For allocated components:
-
The
Material
model'squantity_in_stage(InventoryStages.ALLOCATED)
method calculates:- Sum of quantities moved TO the ALLOCATED stage
- Minus sum of quantities moved FROM the ALLOCATED stage
-
For batched materials:
- The
Material.batched
property (viaquantity_in_stage(InventoryStages.BATCHED)
) -
The
BatchTicket
andBatchMaterial
models track specific details -
For finished materials:
- The
Material.finished
property (viaquantity_in_stage(InventoryStages.FINISHED)
) -
The
ProductionRecord
model tracks completed quantities -
For shipped materials:
- The
Material.shipped
property (viaquantity_in_stage(InventoryStages.SHIPPED)
)
The MaterialTransaction
model is the core tracking mechanism, recording all movements between stages with appropriate quantities. The system optimizes inventory calculations using prefetching and caching with prefetch_inventory_data()
.
How can I be informed of insufficient quantity for materials when a new sales order is entered?
The current model doesn't explicitly implement an alert system for insufficient quantities, but several components can be leveraged to build this functionality:
- Using the
Material.quantity_in_stage()
method: - When a new order is created, the system can check available raw material quantities
-
Compare required quantities (from BOM) against available quantities (RAW stage)
-
Implementing an order validation method:
- Add a method to the
Order
orOrderItem
models that checks material availability -
Calculate requirements based on the
BillofMaterial
for each product -
Using the
get_bom_usages()
method: - This method in the
Material
model already identifies where materials are used -
Can be extended to validate quantities against new orders
-
Signal-based validation:
- Add Django signals to the
Order
orOrderItem
models - Trigger validation when new orders are created or modified
- Raise warnings or prevent creation when insufficient materials are detected
To implement this, I recommend adding:
1. A method to OrderItem
that calculates required materials based on BOM
2. A validation function that compares requirements against available inventory
3. A notification mechanism that alerts users to insufficient quantities
4. An optional reservation system that tentatively allocates materials to orders
This would ensure that sales orders cannot be created or confirmed without sufficient materials available, or at minimum would warn users of potential shortages.