Skip to main content
The stock_request_bom module enhances stock request orders by enabling automatic population of request lines based on a Bill of Materials (BoM), streamlining the process of requesting all components for a manufactured product.

Overview

Module Name: stock_request_bom
Version: 18.0.1.0.1
License: LGPL-3
Dependencies: stock_request, mrp
Author: ForgeFlow, OCA
Category: Warehouse Management
Auto Install: Yes (when both dependencies are met)
This module allows you to select a product’s Bill of Materials and automatically create stock request lines for all components, simplifying the process of requesting materials for production.

Key Features

BoM-Based Line Generation

  • Select a product BoM in stock request order
  • Specify quantity multiplier
  • Automatically generate request lines for all BoM components
  • Quantities calculated based on BoM and multiplier

Dynamic Updates

  • Change quantity BoM to recalculate component quantities
  • Update BoM selection to load different components
  • Clear BoM selection to remove auto-generated lines
  • Manual adjustments to generated lines supported

Flexible Workflow

  • Mix BoM-generated and manually-added request lines
  • Multiple BoMs can be used in same order
  • Update BoM without losing manual entries
  • Supports multi-level BoMs with subassemblies

Installation

This module installs automatically when both stock_request and mrp modules are installed.
1

Install Prerequisites

Ensure these modules are installed:
  • stock_request (Stock Request)
  • mrp (Manufacturing)
2

Automatic Installation

The module installs automatically due to auto_install: True setting.
3

Verify Installation

Check that BoM fields appear in stock request order form.

Configuration

Bill of Materials Setup

Ensure products have properly configured BoMs:
1

Navigate to BoMs

Go to Manufacturing > Products > Bills of Materials.
2

Create or Edit BoM

For each finished product:
  • Set Product (finished product)
  • Add Components with quantities
  • Specify BoM Type: Manufacture this product
  • Save the BoM
3

Verify BoM Active

Ensure BoM is active and not archived.

Product Configuration

Products used in BoM-based requests should:
  • Have Can be Manufactured enabled
  • Have at least one active BoM
  • Have components properly configured

Usage

Auto-Filling from BoM

1

Create Stock Request Order

Go to Stock Requests > Stock Request Orders and click Create.
2

Select Product BoM

In the order form:
  • Product BoM: Select the finished product whose components you need
  • The system loads the BoM for that product
3

Enter Quantity BoM

  • Quantity BoM: Enter how many units of the finished product you’re planning to make
  • Example: If BoM is for 1 unit and you enter 10, components will be calculated for 10 units
4

Auto-Generate Lines

Click outside the field or press Tab:
  • Request lines automatically created for each BoM component
  • Quantities calculated: Component Qty × Quantity BoM
  • UoM matched to component product UoM
5

Review and Adjust

  • Review generated request lines
  • Make manual adjustments if needed
  • Add additional lines not in BoM
6

Confirm Order

Click Confirm to process all request lines.

Updating Quantity

To change the quantity multiplier:
1

Change Quantity BoM

Edit the Quantity BoM field with new value.
2

Recalculation

System recalculates all component quantities based on new multiplier.
3

Verify Changes

Review updated quantities in request lines.
Changing Quantity BoM will update all component line quantities. Manual adjustments to individual lines will be overwritten.

Changing BoM Selection

To load a different BoM:
1

Select Different Product

Change the Product BoM field to another product.
2

Lines Updated

Request lines updated with new BoM’s components.
3

Adjust Quantity

Set Quantity BoM for the new product.

Clearing BoM Selection

To remove BoM-generated lines:
1

Clear Product BoM

Remove the value from Product BoM field.
2

Lines Removed

BoM-generated request lines are removed.
3

Manual Lines Remain

Any manually added lines are preserved.

Data Models

Stock Request Order (Extended)

Adds BoM-related fields:
class StockRequestOrder(models.Model):
    _inherit = 'stock.request.order'
    
    product_bom_id = fields.Many2one(
        'mrp.bom',
        string='Product BOM',
        help='Select a BOM to auto-fill request lines'
    )
    
    bom_product_id = fields.Many2one(
        'product.product',
        string='Product BoM',
        help='Product for which to load BOM'
    )
    
    qty_bom = fields.Float(
        string='Quantity BOM',
        default=1.0,
        help='Quantity multiplier for BOM components'
    )

Onchange Methods

@api.onchange('bom_product_id')
def _onchange_bom_product_id(self):
    # Load BOM for selected product
    # Clear existing BOM-generated lines
    # Generate new lines from new BOM
    
@api.onchange('qty_bom')
def _onchange_qty_bom(self):
    # Recalculate quantities for all BOM lines
    # Multiply component quantities by qty_bom
    
@api.onchange('product_bom_id')
def _onchange_product_bom_id(self):
    # Generate request lines from selected BOM
    # Create line for each BOM component

Views

Stock Request Order Form

Enhanced with BoM fields:
<group name="bom_group" string="Bill of Materials">
    <field name="bom_product_id"/>
    <field name="product_bom_id" 
           domain="[('product_id', '=', bom_product_id)]"/>
    <field name="qty_bom"/>
</group>
BoM section appears above request lines for easy access.

Calculation Logic

Component Quantity Calculation

For each component in the BoM:
request_qty = bom_line.product_qty * qty_bom
Example:
  • BoM component: 5 units
  • Quantity BoM: 3
  • Request line quantity: 5 × 3 = 15 units

UoM Handling

request_uom = bom_line.product_uom_id
# or fallback to:
request_uom = component.uom_id
Component UoM from BoM is used, or product default if not specified.

Use Cases

Production Material Request

Scenario: Production manager needs all materials for a production run.
1

Plan Production

Decide to manufacture 50 units of Product X.
2

Create Request Order

Open new stock request order.
3

Select Product and Quantity

  • Product BoM: Product X
  • Quantity BoM: 50
4

Review Components

System lists all components × 50.
5

Confirm

Confirm to request all materials.

Kitting Operations

Scenario: Assemble kits for customer orders. Setup:
  • Create BoM for kit with all components
  • Use BoM module to request kit components
Benefit: Ensure all kit components requested together.

Project Material Planning

Scenario: Request materials for multiple units in a project. Workflow:
  1. Select product BoM for project deliverable
  2. Set quantity to project requirement
  3. System calculates total material needs
  4. Confirm to request all materials
Benefit: Complete material list for project in one request.

Best Practices

BoM Maintenance

Keep BoMs Updated: Regularly review and update BoMs to ensure accuracy. Outdated BoMs lead to incorrect material requests.
BoM Versions: Use BoM versioning for products with changing specifications.

Request Planning

Buffer Quantities: Consider adding buffer percentage to Quantity BoM to account for waste or defects.
Component Lead Times: Review component lead times before confirming requests to ensure timely availability.

Mixed Requests

Combine Methods: Use BoM generation for main components, then add manual lines for consumables or tooling.
Multiple BoMs: In same order, generate lines from one BoM, then clear and add another BoM’s components.

Integration with Other Modules

Stock Request MRP

When used with stock_request_mrp:
BoM-generated component requests can trigger procurement, while the finished product itself can be manufactured via a separate stock request.
Combined Workflow:
  1. Create order for finished product components (using BoM module)
  2. Confirm to procure/transfer components
  3. Create separate request for finished product
  4. Confirm to trigger manufacturing order
  5. Components already available from first request

Stock Request Purchase

Components in BoM-generated requests can trigger purchase orders:
  1. Select product BoM
  2. Set quantity BoM
  3. Confirm request order
  4. Purchasable components trigger POs
  5. Track all POs from request order

Advanced Features

Multi-Level BoMs

For nested BoMs (BoM with subassemblies):
The module uses the primary BoM level only. For subassemblies, you may need to:
  • Request finished product (triggers MO which handles subassemblies)
  • Or manually create separate requests for subassemblies

BoM Variants

When product has variants:
  • Select specific variant in Product BoM field
  • System loads variant-specific BoM
  • Component quantities based on variant BoM

Phantom BoMs

For phantom/kit BoMs:
  • Module treats same as regular BoMs
  • All components listed in request lines
  • Phantom nature handled during procurement

Troubleshooting

No Lines Generated

Problem: Selecting Product BoM doesn’t create request lines. Solutions:
  1. Verify product has an active BoM
  2. Check BoM is not archived
  3. Ensure BoM has components defined
  4. Verify Quantity BoM is greater than zero
  5. Check BoM company matches request order company

Incorrect Quantities

Problem: Component quantities don’t match expectation. Solutions:
  1. Review BoM component quantities
  2. Check Quantity BoM value
  3. Verify UoM conversions
  4. Ensure BoM quantities are per unit of finished product

Lines Overwritten

Problem: Manual changes lost when updating Quantity BoM. Solutions:
  1. Make manual adjustments after setting final Quantity BoM
  2. Mark BoM-generated lines distinctly (e.g., in notes)
  3. Use separate request orders for BoM and manual requests

Wrong BoM Loaded

Problem: System loads unexpected BoM. Solutions:
  1. Check if multiple BoMs exist for product
  2. Verify BoM is marked as primary/default
  3. Review BoM applicability rules
  4. Check BoM dates and validity

API Examples

Programmatic BoM Line Generation

# Create order and auto-fill from BoM
order = env['stock.request.order'].create({
    'name': 'Production Materials',
    'warehouse_id': warehouse.id,
})

# Set BoM and quantity
order.write({
    'bom_product_id': product.id,
    'qty_bom': 10.0,
})

# Trigger onchange manually if needed
order._onchange_bom_product_id()
order._onchange_qty_bom()

# Request lines now populated
for line in order.stock_request_ids:
    print(f"Component: {line.product_id.name}, Qty: {line.product_qty}")

Reading BoM Data

# Get BoM for a product
bom = env['mrp.bom']._bom_find(product=product)

# List all components
for line in bom.bom_line_ids:
    print(f"Component: {line.product_id.name}")
    print(f"Quantity: {line.product_qty} {line.product_uom_id.name}")

Stock Request Core

Base stock request functionality

Stock Request MRP

Manufacturing order integration

Stock Request Purchase

Purchase order generation for components

MRP Module

Odoo manufacturing and BoM documentation

Calculation Examples

Example 1: Simple BoM

BoM for Product “Chair”:
  • 4 × Leg
  • 1 × Seat
  • 4 × Screw
Request:
  • Product BoM: Chair
  • Quantity BoM: 5
Generated Lines:
  • Leg: 4 × 5 = 20 units
  • Seat: 1 × 5 = 5 units
  • Screw: 4 × 5 = 20 units

Example 2: Fractional Quantities

BoM for Product “Solution”:
  • 0.5 L × Chemical A
  • 0.3 L × Chemical B
  • 2.5 L × Water
Request:
  • Product BoM: Solution
  • Quantity BoM: 10 L
Generated Lines:
  • Chemical A: 0.5 × 10 = 5.0 L
  • Chemical B: 0.3 × 10 = 3.0 L
  • Water: 2.5 × 10 = 25.0 L

Build docs developers (and LLMs) love