From Production to Material Request
When a Production Batch starts, GarmentFlow doesn't wait for someone to manually queue up the materials. It auto-creates the Material Requests needed to move those materials from the Raw Material warehouse to wherever the Batch's operations will run. This page explains exactly what happens, when, and why.
When it fires
The trigger is the start_production action on a Production Batch. Until the Batch starts, no MR is created. When you click Start (or a supervisor moves the Batch into In Progress), GarmentFlow runs _create_material_request() and the MRs appear.
This timing matters: it means materials aren't reserved or queued for transfer until production has actually committed to running the Batch. A Draft Batch isn't pulling materials anywhere; it's just a plan.
What gets created
For each unique target warehouse across the Batch's Operation Steps, GarmentFlow creates one Material Request of type Material Transfer. The fields populated:
- Material Request Type =
Material Transfer— internal warehouse-to-warehouse movement. - Company = the warehouse's company.
- Transaction Date and Schedule Date = the Batch's date.
- Set From Warehouse = the Batch's Raw Material warehouse (sourced from the Production Order, which sources from Garment Manufacturing Settings).
- Set Warehouse = the target Production Unit's warehouse (or the unit's default warehouse if no override).
production_batchcustom field on the MR header = the Batch's name. This is the back-link that ties the MR to its source.- Items table — one row per material from the Batch's materials section, with item code, allocated quantity, UOM, target warehouse, and source warehouse.
If the Batch has Operation Steps running at three different Production Units (Stitching Line A, Wash, Finishing), three MRs get created — one per unit. Each MR carries only the materials destined for that unit.
Idempotency
The function is idempotent. If you re-trigger it (because a Batch was modified and re-started, or the function ran twice), it checks for existing non-cancelled MRs already linked to the Batch via the production_batch field. If a target warehouse already has an MR covering it, that warehouse is skipped on the re-run.
The practical effect: you can't accidentally create duplicate MRs by clicking Start twice. GarmentFlow protects you.
Why this design
A few questions this design answers:
Why one MR per target warehouse, not one big MR? Because each warehouse may be operated by a different team, on a different schedule, with different submission and transfer flows. Splitting by warehouse means each team owns the MRs they need to act on.
Why "Material Transfer" type, not "Material Issue"? Material Issue posts stock against a cost center but doesn't move it to a target warehouse. Material Transfer moves it — which is exactly what we need, because the materials still belong to the company; they're just shifting physical location to where the operation will consume them.
Why is the back-link a custom field? Vanilla ERPNext doesn't model "this MR exists because of that Production Batch." We added the field so GarmentFlow can answer that question — and so the Production Bridge dashboard can show, for any Batch, which MRs are open against it.
What happens after the MR is created
The MR lands in Submitted state, ready to be acted on. From here:
- The warehouse team sees the MR in the Prep view of the Logistics App.
- They confirm the items and quantities (they can swap items, add/remove rows, or escalate shortages from the app).
- They post a Stock Entry (Material Transfer) — the actual movement.
- The MR's status moves to Issued when fully transferred.
That last step — the Stock Entry — is the next page.
A working example
You start a Production Batch for 500 black hoodies. The Batch has three Operation Steps: Stitching Line A, Wash Drum 2, Finishing Bench 4. Each operates out of a different warehouse.
GarmentFlow creates:
- MR-001 → Raw Material → Line A Warehouse. Items: 525 metres of fleece, 1100 metres of rib trim, 1000 ends of cord.
- MR-002 → Raw Material → Wash Drum 2 Warehouse. (Empty — wash doesn't consume new raw materials, only processes WIP. This MR may not be created if no materials are needed.)
- MR-003 → Raw Material → Finishing Bench 4 Warehouse. Items: 500 woven labels, 500 hangtags, 500 polybags.
Two MRs, each headed to the team that runs that unit. Each prep team picks them up, transfers the stock, and the operation can begin.
What to do next
The MR is the request. The Stock Entry is what actually moves the stock.