Skip to content

Stock Cut Order Documentation

Overview

The Stock Cut Order module (stock.cut.order) represents individual order requirements within a cutting operation. Each order specifies a width and quantity that needs to be fulfilled from stock materials, along with flexibility options for quantity matching.


Model Information

Model Name: stock.cut.order
Display Name: (Not explicitly defined)
Key Fields: None (no unique constraint defined)

Features

  • ❌ Audit logging enabled (_audit_log)
  • ❌ Multi-company support (company_id)
  • ❌ Full-text content search (_content_search)
  • ❌ Unique key constraint

Field Reference

Header Fields

Field Type Required Description
cut_id Many2One Parent cutting operation (on_delete="cascade")
width Decimal Required width of the cut material
qty Integer Number of pieces needed at this width
qty_type Selection Controls quantity matching: "allow" for extra qty, "exact" for precise qty
pat_qty Integer Computed field showing actual quantity cut from patterns

Quantity Type Options

Type Code Description
Allow Extra allow Solver can produce more than requested quantity to optimize cutting
Exact Quantity exact Solver must produce exactly the requested quantity

Field Reference

Relationship Fields

Field Type Description
cut_id Many2One Links to stock.cut - Parent cutting operation

Computed Fields

Field Type Description
pat_qty Integer Total quantity cut for this width across all patterns

Computed Fields Functions

get_pat_qty(ids, context)

Calculates the total quantity that will be cut for each order based on all generated cutting patterns.

Logic: 1. Retrieves the parent cutting operation 2. Iterates through all patterns in the cutting operation 3. Sums quantities for each width across all patterns (considering pattern repeat count) 4. Matches totals to each order by width

Returns: Dictionary mapping order ID to total cut quantity

Example:

# Pattern 1: Stock 300, repeated 5 times
# - Cut 100 x 2
# - Cut 150 x 1

# Pattern 2: Stock 250, repeated 3 times
# - Cut 100 x 1

# Order for width 100:
# pat_qty = (2 * 5) + (1 * 3) = 13 pieces


Common Use Cases

Use Case 1: Create Order Requirements

# Create order records as part of a cutting operation
cut_id = get_model("stock.cut").create({
    "date": "2025-10-27",
    "orders": [
        ("create", {
            "width": 100.0,
            "qty": 50,
            "qty_type": "exact"    # Must be exactly 50 pieces
        }),
        ("create", {
            "width": 150.0,
            "qty": 30,
            "qty_type": "allow"    # Can be 30 or more
        }),
        ("create", {
            "width": 75.0,
            "qty": 100,
            "qty_type": "exact"
        })
    ],
    "stock": [...]
})

Use Case 2: Verify Order Fulfillment

# After solving, check if orders are fulfilled
cut = get_model("stock.cut").browse(cut_id)

for order in cut.orders:
    fulfillment = (order.pat_qty / order.qty) * 100
    status = "✓" if order.pat_qty >= order.qty else "✗"

    print(f"{status} Width {order.width}: Ordered {order.qty}, Cut {order.pat_qty} ({fulfillment:.1f}%)")

Use Case 3: Flexible vs Exact Orders

# Use "allow" for standard stock items where overproduction is acceptable
standard_orders = [
    ("create", {"width": 100.0, "qty": 50, "qty_type": "allow"}),
    ("create", {"width": 150.0, "qty": 30, "qty_type": "allow"}),
]

# Use "exact" for custom orders or expensive materials
custom_orders = [
    ("create", {"width": 123.5, "qty": 25, "qty_type": "exact"}),
    ("create", {"width": 87.3, "qty": 15, "qty_type": "exact"}),
]

cut_id = get_model("stock.cut").create({
    "orders": standard_orders + custom_orders,
    "stock": [...]
})

Understanding Quantity Types

Allow Extra Quantity (allow)

When set to "allow", the optimization solver has flexibility to produce more pieces than requested if it reduces overall waste. This is ideal for: - Standard products that can be stored - Materials with low holding costs - Items with predictable future demand

Example:

# Order: 50 pieces of width 100
{"width": 100.0, "qty": 50, "qty_type": "allow"}

# Solver might produce: 52 pieces
# Because it creates a more efficient cutting pattern

Exact Quantity (exact)

When set to "exact", the solver must produce exactly the requested quantity. This is critical for: - Custom orders with specific customer requirements - Expensive or specialized materials - Items with no storage capacity - Just-in-time manufacturing

Example:

# Order: 25 pieces of width 123.5
{"width": 123.5, "qty": 25, "qty_type": "exact"}

# Solver will produce: exactly 25 pieces
# Even if it means higher waste


Relationship with Patterns

Each order width is matched against pattern cuts to calculate pat_qty:

Order (width=100, qty=50)
Matched in Pattern 1:
    - width1=100, qty1=2, num=10 → contributes 20 pieces
Matched in Pattern 2:
    - width2=100, qty2=1, num=15 → contributes 15 pieces
Matched in Pattern 3:
    - width3=100, qty3=3, num=5 → contributes 15 pieces
Total pat_qty = 20 + 15 + 15 = 50 pieces ✓

Best Practices

1. Choose Appropriate Quantity Type

# Good: Use "allow" for standard inventory items
standard_order = {
    "width": 100.0,
    "qty": 50,
    "qty_type": "allow"  # Overproduction is acceptable
}

# Good: Use "exact" for custom orders
custom_order = {
    "width": 123.5,
    "qty": 25,
    "qty_type": "exact"  # Must be precise
}

# Bad: Using "exact" for everything increases waste
bad_order = {
    "width": 100.0,
    "qty": 50,
    "qty_type": "exact"  # Unnecessary constraint
}

2. Validate Orders Before Solving

# Verify order widths are feasible
def validate_orders(cut_id):
    cut = get_model("stock.cut").browse(cut_id)

    max_stock_width = max(s.width for s in cut.stock)

    for order in cut.orders:
        if order.width > max_stock_width:
            raise Exception(f"Order width {order.width} exceeds max stock width {max_stock_width}")

        if order.qty <= 0:
            raise Exception(f"Order quantity must be positive, got {order.qty}")

3. Monitor Fulfillment Rates

Track the ratio of pat_qty to qty to ensure orders are being fulfilled efficiently.


Model Relationship Description
stock.cut Many2One Parent cutting operation that contains this order
stock.cut.pattern Related Patterns that fulfill this order's requirements

Troubleshooting

"Orders not fulfilled after solving"

Cause: Insufficient stock quantity or widths
Solution: - Verify stock quantities are sufficient - Check that stock widths are compatible with order widths - Review qty_type settings - "exact" may be too restrictive

"pat_qty is None or zero"

Cause: No patterns generated, or width doesn't match any pattern cuts
Solution: - Run solve() on the parent cutting operation - Verify order width matches available stock widths - Check that order width is not larger than all stock widths

"Excessive overproduction with 'allow' type"

Cause: Solver optimizing for minimum waste at expense of overproduction
Solution: - Consider switching to "exact" for specific orders - Adjust stock quantities to better match order requirements - Review solver parameters if configurable


Performance Tips

1. Group Similar Widths

Orders with similar widths are more likely to be cut together efficiently:

# Good: Orders are grouped by similar widths
orders = [
    {"width": 100.0, "qty": 50},
    {"width": 105.0, "qty": 30},
    {"width": 150.0, "qty": 40},
    {"width": 155.0, "qty": 25},
]

2. Use Realistic Quantities

Very small or very large quantities relative to stock may result in inefficient patterns.


Version History

Last Updated: October 2025
Model Version: stock_cut_order.py
Framework: Netforce


Additional Resources

  • Stock Cut Documentation: stock.cut
  • Stock Cut Pattern Documentation: stock.cut.pattern
  • Stock Cut Stock Documentation: stock.cut.stock

This documentation is generated for developer onboarding and reference purposes.