Introducing a new way to review your PRs.

Read the announcement

frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)

View on GitHub

20 documents · Updated Nov 23, 2026

docs / manufacturing-and-subcontracting

Manufacturing and subcontracting

Manufacturing turns a demand signal into finished stock by linking product structure, material supply, planned work, shop-floor execution, stock movement, and cost. The flow supports work done inside the company and work sent to a supplier while keeping quantity, date, warehouse, and cost links with the demand that caused the work.

Manufacturing lifecycle

The lifecycle starts with a forecast, order, or other material need. A production plan chooses how to meet that need, then work orders, job cards, stock events, or supplier receipts record the result.

This diagram shows how demand becomes material and capacity plans before it returns as finished stock and cost.

flowchart LR
    D[Forecast or order demand] --> P[Production Plan]
    P --> B[BOM demand]
    B --> S[Purchase, transfer, or reservation]
    P --> W[Work Order]
    W --> J[Job Cards]
    J --> I[In-house work]
    I --> M[Manufacture stock event]
    P --> PO[Subcontracting order]
    PO --> SM[Material sent to supplier]
    SM --> SR[Subcontracting Receipt]
    M --> F[Finished stock and actual cost]
    SR --> F

In-house work records material use, operation time, output, process loss, and secondary output. Supplier work adds the custody of company-owned material and the supplier service cost. Both paths update progress against the source demand.

References: erpnext/…/production_plan.py• L158-187 erpnext/…/production_plan.py• L562-600 erpnext/…/status.py• L110-169

Demand commitments

A Blanket Order records a dated promise to sell to a customer or buy from a supplier. It gives later orders a shared party, item quantity, currency, price basis, and rate basis.

The commitment limits later orders by date and remaining quantity. Currency and unit conversion keep the agreed amount usable when a later transaction maps from the commitment.

References: erpnext/…/blanket_order.py• L70-130 erpnext/…/blanket_order.py• L150-209 erpnext/…/blanket_order.py• L317-345

Demand forecasts

A Sales Forecast expresses expected stock-item demand before a firm order exists. A forecast can feed a Master Production Schedule, so expected demand enters the same planning flow as sales orders and material requests.

The Master Production Schedule collects dated demand, checks the selected BOM, and estimates the time needed for the item and its components. It follows the longest component path, so purchased material and lower-level production can affect the required completion date.

References: erpnext/…/sales_forecast.py• L35-80 erpnext/…/master_production_schedule.py• L58-125 erpnext/…/master_production_schedule.py• L170-230

Product definition

The product definition states what an item needs and how work produces it. A BOM is the shared source for material demand, operations, intermediate output, process loss, secondary output, and expected cost.

Bills of materials

A bill of materials (BOM) defines a finished item, its output quantity, components, optional sub-assemblies, operations, and secondary outputs. A multi-level BOM can keep a sub-assembly as a separate supply item or expand it into lower-level demand.

Operations can produce semi-finished items before the final item. A stage can use a child BOM or direct material rows. Batch-split work supports piece-level output when a stage creates new batches.

Formulated products can derive component quantities from percentages. A balance component can fill the remaining share when the component UOM supports the required conversion.

The BOM is also a revision point. Teams can compare product rows and create a variant BOM without changing the submitted source. The active default BOM becomes the normal product definition for later planning.

References: erpnext/…/bom.py• L298-340 erpnext/…/bom.py• L342-458 erpnext/…/bom.py• L624-724 erpnext/…/bom.py• L791-865 erpnext/…/bom.py• L995-1102

BOM explosion

BOM explosion converts a multi-level product definition into a flat view of component demand. It keeps operation links, warehouses, supplier sourcing, and item settings with each material group so planning can choose the right supply action.

Repeated material lines are grouped by item and stock unit. The source description and warehouse come from a stable BOM line. A real material line remains visible even when another line for the same item is a phantom component.

References: erpnext/…/exploded_items.py• L18-70 erpnext/…/bom_explosion.py• L17-47 erpnext/…/bom_explosion.py• L50-113 erpnext/…/bom_explosion.py• L153-260

Design-to-BOM flow

The BOM Creator turns a product design into linked BOMs. It maps design parts to items, shows revisions, and creates assembly BOMs in dependency order.

The design stays separate from submitted BOMs. A new design revision can therefore be reviewed before it becomes the next product definition. Design material cost follows the same item, BOM, UOM, warehouse, supplier, and currency rules used by BOM costing.

References: erpnext/…/bom_creator.js• L4-18 erpnext/…/bom_creator.js• L92-256 erpnext/…/material_cost.py• L18-76

Routing and capacity

A routing provides an ordered set of operations. Each operation points to a workstation or workstation type and a time basis, so the same work sequence supports job execution, expected cost, and capacity planning.

The scheduling view places operation tasks around dependencies, material and supplier lead times, calendars, holidays, existing work, and workstation capacity. It can plan forward from a start date or backward from a due date. Workstation load includes booked job-card time and active plan blocks.

References: erpnext/…/operations.py• L36-62 erpnext/…/engine.py• L40-94 erpnext/…/engine.py• L97-165 erpnext/…/loaders.py• L17-68

Cost model

Expected BOM cost gives a pre-production view of material and operating cost. It can use valuation, purchase data, a buying price list, or the unit cost of a child BOM. Process loss changes the good quantity used for unit cost.

Actual cost comes from work and stock records. Work orders roll up planned and actual operation cost. Manufacture movements add material, operating, non-stock, secondary-output, and corrective cost to the value of the result.

References: erpnext/…/costing.py• L30-64 erpnext/…/costing.py• L77-170 erpnext/…/material_cost.py• L78-168 erpnext/…/operations_cost.py• L16-80 erpnext/…/operations_cost.py• L176-253

Production planning

Production planning converts demand into a supply plan. It groups finished-item demand, expands BOMs into lower-level need, compares that need with stock and open supply, and prepares records for manufacture, purchase, transfer, reservation, or supplier processing.

Demand sources

A Production Plan can start from open Sales Orders or Material Requests. It keeps the source item, quantity, warehouse, date, project, and chosen BOM linked to each plan row.

The plan can combine matching demand while keeping source references. It considers existing supply, safety stock, minimum order quantity, process loss, sub-assemblies, and supplier-sourced components. It can also reserve raw material and in-house sub-assembly supply.

References: erpnext/…/sales_order_planning.py• L19-45 erpnext/…/sales_order_planning.py• L148-178 erpnext/…/production_plan.py• L284-315 erpnext/…/production_plan.py• L353-389

Material demand

BOM explosion converts planned finished-item quantity into lower-level material quantity. The plan can keep a sub-assembly as a separate supply item or expand it based on the selected manufacturing path.

Material need is compared with stock, open supply, reservations, safety stock, lead time, and process loss. The result points to the next supply action:

  • Purchase for a shortage supplied by a vendor.
  • Material Transfer for stock available at another location.
  • Manufacture for an in-house item or sub-assembly.
  • Subcontracting for a supplier-made sub-assembly.

A raw-material group warehouse widens the availability search across child warehouses. The receiving warehouse remains a concrete leaf warehouse. Transfer stock is removed before purchase-unit conversion and rounding so the request represents the remaining shortage.

References: erpnext/…/material_request.py• L184-200 erpnext/…/material_request.py• L397-468 erpnext/…/material_request.py• L482-551 erpnext/…/planning_queries.py• L80-146

Supply records

After submission, a plan can create Work Orders for finished goods and in-house sub-assemblies. It can create Material Requests for shortages and supplier orders for subcontracted sub-assemblies.

Each generated record keeps a link to the source plan and item row. Later actions use the remaining quantity, so repeated planning does not create duplicate supply for the same demand.

References: erpnext/…/production_plan.py• L562-600 erpnext/…/production_plan.py• L642-656 erpnext/…/material_request.py• L47-87

Plan scheduling

Plan scheduling turns material and operation demand into proposed dates and workstation blocks. It uses operation order, material and supplier lead times, calendars, holidays, existing load, and capacity.

The system can show a proposal before it is applied. It refuses an incomplete proposal and will not re-schedule a plan that already has active Work Orders or Purchase Orders. If draft plan rows change, its old schedule is cleared so dates do not describe an earlier plan. For the detailed planning and execution flow, see Production planning and execution.

References: erpnext/…/plan_adapter.py• L20-119 erpnext/…/plan_adapter.py• L122-174 erpnext/…/production_plan.py• L173-188

Material requirements view

The Material Requirements Planning report gives a date and warehouse view of planned and unplanned demand. It combines Master Production Schedule data with sales orders, work orders, purchase orders, stock, safety stock, and lead times.

This view helps identify when lower-level material must be available. It includes demand beyond the current schedule so open order need is not hidden by an incomplete forecast or plan.

References: erpnext/…/material_requirements_planning_report.py• L30-102 erpnext/…/material_requirements_planning_report.py• L104-180

Production execution

Production execution controls how a planned quantity becomes work, material movement, output, and actual cost. The Work Order is the main execution record because it connects the item and BOM to operations, warehouses, reservations, source demand, and output.

Work orders

A Work Order authorizes production of one item from one BOM. It carries required materials, operations, planned dates, warehouses, planned and actual cost, and links to the Production Plan, Sales Order, or Material Request that caused the work.

The material view tracks required, requested, picked, transferred, consumed, returned, and reserved quantity. New material actions use the remaining requirement so supply does not exceed the authorized Work Order quantity.

Submitting the Work Order creates Job Cards for its operations and updates demand and reservation links. It can also support process loss, secondary output, serial or batch tracking, alternative finished goods, and semi-finished output.

References: erpnext/…/mapper.py• L110-156 erpnext/…/required_items.py• L37-71 erpnext/…/required_items.py• L92-166 erpnext/…/operations.py• L118-178 erpnext/…/status.py• L34-60

Stock reservation

Stock reservation holds material for a Work Order before physical transfer or consumption. The reservation follows the material from source stock to work in progress and then to consumption, while serial and batch identity stays tied to the reserved quantity.

The reservation is updated from submitted stock events. A cancelled transfer can lower the transferred amount and restore the unconsumed reservation. This keeps the available quantity and Work Order material view aligned.

References: erpnext/…/reservation.py• L61-109 erpnext/…/reservation.py• L107-177 erpnext/…/reservation.py• L180-214

Job cards

A Job Card represents work on one operation within a Work Order. It records the assigned quantity, workstation, material readiness, time, completed quantity, process loss, quality state, and operating cost.

The operator flow moves material when required, starts or pauses time, completes a quantity, and submits the work. Completed, pending, and process-loss quantities must account for the operation quantity. Later operations cannot complete more than the quantity released by earlier operations.

Job Cards can split work by quantity or operation batch size. A subcontracted card uses supplier-work actions instead of the in-house timer and output path. For the detailed execution flow, see Production planning and execution.

References: erpnext/…/job_card.py• L162-220 erpnext/…/job_card.py• L248-285 erpnext/…/job_card.js• L314-357 erpnext/…/job_card.js• L444-625 erpnext/…/job_card.js• L628-641

Material and output movements

Stock movements record the physical result of production. Material can move from source stock to work in progress, be consumed during production, and be replaced by finished or semi-finished output in its target warehouse. Secondary output and process loss can use their own destinations.

The movement checks the Work Order quantity, material basis, operation completion, warehouse, serial or batch data, and configured overproduction allowance. A return puts unused transferred material back into available stock. Work Order status then reflects reservation, progress, produced quantity, loss, and completion.

References: erpnext/…/required_items.py• L189-220 erpnext/…/status.py• L110-169 erpnext/…/status.py• L171-211

Quality cost view

Corrective Job Cards capture time and operating cost for work that addresses poor quality. The Cost of Poor Quality report presents that cost with the related Work Order, item, operation, workstation, and serial or batch context.

When a report date range cuts through a time log, the report uses only the overlapping time. This keeps the reported minutes and cost within the selected period.

References: erpnext/…/cost_of_poor_quality_report.py• L18-62 erpnext/…/cost_of_poor_quality_report.py• L92-138

Supplier subcontracting

Supplier subcontracting covers production work performed outside the company. The company orders a service-backed item, sends company-owned material to the supplier, and records the returned quantity, material use, and service cost. For the supplier and receipt lifecycle, see Subcontracting operations.

Subcontracting orders

A subcontracting flow starts from a submitted Purchase Order and its Subcontracting Order. The order identifies the supplier, finished item, BOM, service item, supplied material, warehouse, planned quantity, sent quantity, and received quantity.

The supplier service and supplied material remain in one production and commercial view. A Production Plan can send one sub-assembly to a supplier while it creates Work Orders for other sub-assemblies of the same finished item.

References: erpnext/…/production_plan.py• L580-600 erpnext/…/material_request.py• L47-59 erpnext/…/costing.py• L38-55

Material custody

The company keeps ownership control of material sent to the supplier. Send-to-Subcontractor movements stay linked to the Subcontracting Order and cannot exceed its required quantity within the allowed limit.

The order tracks required, supplied, reserved, consumed, returned, and net supplied quantity. When supplier work belongs to a Work Order, the sent quantity also changes the Work Order reservation. A cancelled transfer restores the available reservation.

References: erpnext/…/reservation.py• L103-177 erpnext/…/reservation.py• L227-249

Subcontracting receipts

A Subcontracting Receipt records what the supplier returns. It separates received, accepted, and rejected quantity and records raw material consumed for each returned item. It can also record process loss, secondary output, inspection, serial or batch data, and extra cost.

The receipt updates the supplier order, consumes supplied material, posts stock and accounting effects, and updates linked production progress. A return reverses the related quantity and stock effects within the available amount. See Subcontracting operations for the supplier and receipt lifecycle.

References: erpnext/…/job_card.js• L628-641 erpnext/…/reservation.py• L227-249

Operating controls

Manufacturing Settings, Stock Settings, Buying Settings, BOM choices, and warehouse defaults decide how the same business flow behaves. They control reservation, material transfer, consumption timing, capacity planning, operation gates, process loss, and output valuation.

The main choices are:

  • Reserve stock at Production Plan or Work Order stage.
  • Transfer material before manufacture or consume it at the manufacture event.
  • Base consumption on the BOM or on material transferred to work in progress.
  • Control material at Work Order or Job Card level.
  • Include process loss in planning and completion.
  • Allow extra transfer, overproduction, alternative finished goods, or automatic serial and batch creation.
  • Use operation calendars and workstation capacity when scheduling.
  • Check supplier consumption against the BOM or transferred material.

Warehouses must belong to the same company as the production record. A group warehouse can scope availability, but a Material Request needs a concrete receiving warehouse.

References: erpnext/…/production_plan.py• L144-230 erpnext/…/material_request.py• L128-151 erpnext/…/reservation.py• L65-105

Change checklist

When these files or sections are changed, remember to consider these:

  • BOM structure or explosion changes affect material demand, Work Order materials, supplier demand, intermediate output, and expected cost.
  • BOM operation-output, batch-split, formulation, or secondary-output changes must keep quantity, UOM conversion, stage output, and cost allocation aligned.
  • BOM cost changes must keep child-BOM unit cost, process-loss good quantity, currency conversion, and actual stock cost consistent.
  • Production Plan changes must preserve source-demand quantity, warehouse company scope, reservations, schedule clearing, and the split between in-house and supplier supply.
  • Material planning changes must preserve group-warehouse availability, concrete receiving warehouses, transfer subtraction, UOM conversion, lead times, and remaining quantity.
  • Scheduling changes must preserve dependency order, capacity limits, booked load, supplier lead time, incomplete-proposal checks, and the rule that active orders block re-scheduling.
  • Work Order changes must preserve BOM refresh, required-item quantities, reservation hand-off, operation targets, Job Card creation, process-loss accounting, and demand links.
  • Job Card changes must preserve material readiness, operation sequence, split quantity, time logs, quality gates, completed/pending/loss balance, and supplier-work behavior.
  • Subcontracting changes must preserve Purchase Order, Subcontracting Order, supplied-material, receipt, Work Order, and reservation links.
  • Forecast and Master Production Schedule changes must preserve stock-item scope, company and warehouse scope, forecast period dates, BOM validity, and cumulative component lead time.
  • Blanket Order quantity, price, or currency changes must preserve party, dates, UOM quantity, allowance, price-list currency, conversion rate, and downstream order mapping.

Important failure modes

TriggerConsequenceGuard
A plan uses a BOM for a different itemMaterial and work demand describe the wrong productValidate the BOM output against the planned item before submission
A BOM has invalid intermediate, phantom, or batch-split outputThe product tree cannot produce a safe intermediate resultRequire valid stage output and item settings for the selected production path
A repeated BOM item uses the wrong source linePlanning applies the wrong description or warehouseSelect a stable representative line while preserving real material lines
Formulation percentages or UOM conversion are invalidComponent quantity and cost do not match the finished quantityRequire a valid balance rule or a complete percentage total with usable conversion
A plan changes after schedulingDates no longer describe the current product demandClear the old draft schedule when plan rows change
A plan is re-scheduled after orders existNew dates conflict with active Work Orders or Purchase OrdersCancel the linked orders before applying a new schedule
A task has a dependency cycle or no capacityThe schedule is incompleteReject incomplete proposals and show the unscheduled reason
A group warehouse is used as a receiving warehouseA Material Request targets a location that cannot receive stockUse the group only for availability and require a concrete receiving warehouse
Transfer stock is counted after purchase demand is calculatedThe plan requests more material than the shortageRemove transfer stock before UOM conversion and rounding
Work Orders exceed a Production Plan row after process lossSupply exceeds the planned demandLock the plan row and validate committed quantity with the configured allowance
A Work Order supplies more than its remaining requirementMaterial demand exceeds the authorized production quantityCompare requested, picked, transferred, consumed, and produced quantity with the requirement
A Job Card starts before material or prior-operation output is readyWork progress moves ahead of its inputsEnforce material readiness and operation sequence gates
Manufacture output is recorded before the operation is completeFinished stock and work progress disagreeRequire the operation result and validate output against the Work Order
A supplier receives more material than the order allowsCompany-owned stock remains outside the company without an order basisLimit net supplied quantity to the order requirement and allowance
A supplier receipt has no accepted or rejected quantityThe receipt records no usable stock resultRequire a stock result and check available supplied material
A corrective time log overlaps the report rangePoor-quality cost is overstated or understatedClip time logs to the selected date range before calculating minutes and cost
A forecast includes a non-stock item or mismatched company warehouseExpected demand cannot enter the stock planning flowValidate stock-item type, company, parent warehouse, and dates
A Blanket Order is outside its dates or allowanceA later order uses an expired or excess commitmentCheck date, status, party, currency, item, and remaining quantity before mapping

Key files

FileWhy to read it
erpnext/…/bom.pyDefines the product structure, BOM validity, stage output, and links to BOM services.
erpnext/…/costing.pyExplains expected material and operation cost, child-BOM cost, process loss, and currency handling.
erpnext/…/exploded_items.pyShows how a product tree becomes a flat material view.
erpnext/…/operations_cost.pyShows how operation, workstation, non-stock, and corrective costs reach stock output.
erpnext/…/material_cost.pyShows how a design estimates part cost before it becomes a submitted BOM.
erpnext/…/production_plan.pyCoordinates demand links, validation, reservation, schedule clearing, and downstream supply.
erpnext/…/bom_explosion.pyShows how BOM levels become planned material rows.
erpnext/…/material_request.pyExplains stock scope, shortage actions, transfer choices, supplier items, and UOM handling.
erpnext/…/work_order_quantities.pyDefines how plan-row quantity, process loss, produced quantity, and overproduction allowance interact.
erpnext/…/plan_adapter.pyConnects a Production Plan to schedule tasks, lead times, proposal checks, and saved dates.
erpnext/…/engine.pyDefines dependency-aware forward and backward capacity scheduling.
erpnext/…/loaders.pyShows how workstation calendars and existing Job Card and plan load affect capacity.
erpnext/…/mapper.pyShows how an item and BOM become a Work Order and how related records are mapped.
erpnext/…/required_items.pyDefines Work Order material requirements and quantity rollups.
erpnext/…/reservation.pyDefines reservation hand-off across transfer, consumption, cancellation, and output.
erpnext/…/operations.pyConnects Work Order operations to Job Cards, planned dates, and actual operating cost.
erpnext/…/status.pyExplains Work Order progress, completion, process loss, and overproduction checks.
erpnext/…/job_card.pyDefines material readiness, operation progress, time, quantity, quality, and cost state.
erpnext/…/job_card.jsShows the operator flow for moving material, starting work, completing quantity, and supplier work.
erpnext/…/master_production_schedule.pyConnects forecast or actual demand to BOM validity and cumulative lead time.
erpnext/…/sales_forecast.pyDefines forecast periods, stock-item demand, and forecast validation.
erpnext/…/material_requirements_planning_report.pyShows the date and warehouse view of planned and open material demand.
erpnext/…/cost_of_poor_quality_report.pyShows how corrective work time becomes a poor-quality cost view.