About BOM Template.

I have set an Item template on BOM Finished goods field and another item template over Raw material field. When I am going to create the Work order, how should I consume the varients of the set Item template on Raw material field.

In ERPNext, if you set Item Templates (i.e., “Template Items” with variants) in the BOM for raw materials, the system will not automatically pick a specific variant when you create a Work Order — it will use exactly the Item Code you’ve set in the BOM.

That means if your BOM says RAW-TEMPLATE and that’s a template (non-stock) item, the Work Order will not know which variant (e.g., RAW-TEMPLATE-RED, RAW-TEMPLATE-BLUE) to consume unless you explicitly tell it.


How to handle raw material variants in a Work Order

Here are the common approaches:

1. Create BOMs for each variant

  • Create one BOM per finished goods variant, and set the raw materials as the exact variants to be used.
  • Example:
    • BOM for FG-RED → raw material RAW-TEMPLATE-RED
    • BOM for FG-BLUE → raw material RAW-TEMPLATE-BLUE
  • Pros: No confusion during production; fully automated.
  • Cons: More BOM records to maintain.

2. Use “Update Raw Materials” in the Work Order

  • Keep the BOM linked to the template item for raw materials.
  • After creating the Work Order, go to the Raw Materials table and manually change the template item to the specific variant you are consuming.
  • This works if the variant choice is made just before production.
  • Pros: Single BOM.
  • Cons: Manual step every time.

3. Custom Script for Variant Selection

  • Add a Custom Field in the Work Order to select a raw material variant (e.g., Color, Size).
  • Use a Client Script or Server Script to replace the template item in the Work Order’s raw materials table with the selected variant before submission.
  • Pros: Keeps BOM maintenance minimal and ensures correct stock deduction.
  • Cons: Requires scripting knowledge.

4. Use “Attribute-driven BOM selection” (Custom Feature)

ERPNext doesn’t natively do attribute-based raw material substitution, but you can:

  • Write a small app or hook on the before_submit of Work Order.
  • Pull the correct variant based on Finished Goods variant attributes.
  • This way, raw material variants are automatically matched.

Important:
If your BOM uses a template item and you don’t replace it with an actual stock variant before manufacturing, ERPNext will not be able to reserve or consume stock because template items are not stock items.