Skip to content

Stock Location Documentation

Overview

The Stock Location module (stock.location) manages all storage locations within the warehouse management system. Locations define where inventory is physically or logically stored, including internal warehouses, customer sites, supplier locations, and virtual locations for production, waste, and inventory adjustments.


Model Information

Model Name: stock.location
Display Name: Location
Key Fields: name

Features

  • ❌ Audit logging disabled
  • ❌ Multi-company support (company_id available but not enforced)
  • ✅ Full-text content search enabled
  • ✅ Unique key constraint on name

Location Types

Type Code Description Use Case
Internal internal Physical warehouse locations Main warehouses, storage areas
Customer customer Customer delivery locations Shipping destinations
Supplier supplier Supplier/vendor locations Receiving from suppliers
Inventory Loss inventory Inventory adjustment location Damaged goods, losses
Production production Manufacturing/production Work-in-progress, assembly
Waste waste Disposal/waste location Expired or discarded items
Transform transform Product transformation Item conversions
View view Parent grouping location Hierarchical organization
Other other Miscellaneous locations Special purposes

Key Fields Reference

Header Fields

Field Type Required Description
name Char Unique location name (max 256 chars)
code Char Short code for location
type Selection Location type (internal/customer/supplier/etc.)
active Boolean Whether location is active (default: True)
description Text Detailed location description

Accounting Fields

Field Type Description
account_id Many2One Inventory account for perpetual costing
track_id Many2One Tracking category for analytics

Hierarchy Fields

Field Type Description
parent_id Many2One Parent location (must be type "view")

Reference Fields

Field Type Description
company_id Many2One Operating company
company2_id Many2One Secondary company (for transfers)
contact_id Many2One Associated contact (for customer/supplier)
address_id Many2One Physical address

Relationship Fields

Field Type Description
comments One2Many Discussion thread
products One2Many Stock balances at this location
stock_moves One2Many All stock movements (in/out)

Computed Fields

Field Type Description
balance Decimal Total inventory quantity
balance_90d Json 90-day balance history chart data

API Methods

1. Create Location

Method: create(vals, context)

Creates a new storage location.

Example:

# Create internal warehouse location
loc_id = get_model("stock.location").create({
    "name": "Warehouse - Zone A",
    "code": "WH-A",
    "type": "internal",
    "account_id": 100,
    "description": "Main warehouse storage zone A"
})


2. Get Balance

Method: get_balance(ids, context)

Calculates total inventory quantity at location(s).

Example:

# Get current balance
balance = get_model("stock.location").get_balance([123])
# balance = {123: 1500.0}

# Get balance as of specific date
balance_hist = get_model("stock.location").get_balance(
    [123], 
    context={"date_to": "2025-09-30"}
)


3. Compute Balance

Method: compute_balance(ids, product_id, date, lot_id, container_id, uom_id)

Computes detailed balance for specific product at location(s).

Example:

# Get product balance at location
balance = get_model("stock.location").compute_balance(
    ids=[10],
    product_id=100,
    date="2025-10-27 23:59:59"
)
# balance = {"bal_qty": 150.0, "bal_amount": 7500.0, "bal_qty2": 0}


Common Use Cases

Use Case 1: Setup Warehouse Structure

# 1. Create main warehouse (parent)
main_wh = get_model("stock.location").create({
    "name": "Central Warehouse",
    "code": "WH-CENTRAL",
    "type": "view",  # Parent location
    "company_id": 1
})

# 2. Create storage zones
receiving = get_model("stock.location").create({
    "name": "Central Warehouse - Receiving",
    "code": "WH-RECV",
    "type": "internal",
    "parent_id": main_wh,
    "account_id": 100
})

Use Case 2: Check Stock Availability

# Get current stock balance
location_id = 10
product_id = 100

balance = get_model("stock.location").compute_balance(
    ids=[location_id],
    product_id=product_id
)

available_qty = balance["bal_qty"]

if available_qty >= required_qty:
    print("Stock available for order")

Model Relationship Description
stock.balance One2Many Product quantities at this location
stock.move One2Many All movements in/out of location
stock.journal Many2One Journals with default locations
stock.picking Indirect Pickings using this location
account.account Many2One Inventory valuation account

This documentation is generated for developer onboarding and reference purposes.