Skip to content

Stock Count Mobile Add Documentation

Overview

The Stock Count Mobile Add module (stock.count.mobile.add) is a transient wizard model that provides a mobile-friendly interface for adding multiple count lines to a mobile count session. It acts as a helper/wizard to simplify the batch addition of products based on various criteria such as category, lot type, and pricing options. This wizard is optimized for mobile workflows where quick configuration and execution are essential.


Model Information

Model Name: stock.count.mobile.add
Display Name: Stock Count Add (Mobile)
Transient: ✅ Yes (temporary wizard data)

Features

  • Transient model - Data not permanently stored
  • Wizard interface - Simplified mobile-friendly form
  • Batch line addition - Add multiple products at once
  • Filter options - By product, category, UOM, lot type
  • Quick configuration - Set default quantities and prices

Understanding Transient Models

What is a Transient Model?

A transient model (_transient = True) stores data temporarily:

  • No permanent database storage: Data exists only during the session
  • Wizard/dialog purpose: Used for temporary data collection
  • Automatic cleanup: Data removed after use
  • Performance benefit: No database bloat from temporary records

Why Use Transient for Mobile Add?

  1. Mobile bandwidth: Reduce data transfer by not storing wizard state
  2. Session-based: Mobile users complete wizard in one session
  3. No history needed: Configuration choices don't need persistence
  4. Clean database: Avoid clutter from temporary selections

Key Fields Reference

Wizard Configuration Fields

Field Type Required Description
stock_count_id Many2One Target mobile count to add lines to
product_id Many2One Specific product to add (optional filter)
categ_id Many2One Product category filter
sale_invoice_uom_id Many2One Unit of measure filter
lot_type Selection Filter by lot tracking requirement
qty_type Selection How to initialize new quantities
price_type Selection How to initialize cost prices

Field Options Explained

Lot Type Options

Value Label Description
with_lot With Lot Only add products that have lot/serial tracking
without_lot Without Lot Only add products without lot/serial tracking
(empty) All Add both lot-tracked and non-lot products

Mobile Use Case: - With Lot: Scanning serialized items like electronics, tools - Without Lot: Counting bulk items like screws, cables - All: General purpose counting


Quantity Type Options

Value Label Description Mobile Scenario
previous Copy Previous Qty Start with system quantity Guided counting - verify expected qty
reset Set Qty To Zero Start at zero Blind counting - only count what you see

Recommendation for Mobile: - Blind count: Use reset - user scans/enters only physical items - Verification count: Use previous - user confirms or adjusts expected qty


Price Type Options

Value Label Description
previous Copy Previous Cost Price Use current stock balance cost
product Copy Cost Price From Product Use product master cost price
reset Set Cost Price To Zero Start with zero cost

Mobile Consideration: Price is typically handled by system, not mobile user. Usually set to previous or product.


API Methods

1. Add Lines (Wizard Action)

Method: add_lines(ids, context)

Executes the wizard to add filtered lines to the mobile count.

Parameters: - ids (list): Wizard record ID (transient) - context (dict): Additional context options

Behavior: 1. Reads wizard configuration (filters, qty type, price type) 2. Builds context for stock.count.add_lines() method 3. Calls add_lines on target count with filters 4. Redirects mobile user back to count form

Returns: Navigation dict to count form

Example:

# Wizard is typically invoked from mobile UI
# User fills wizard form, then:

wizard_id = context.get("wizard_id")
result = get_model("stock.count.mobile.add").add_lines([wizard_id])

# Returns:
# {
#     "next": {
#         "name": "stock_count",
#         "mode": "form",
#         "active_id": count_id
#     }
# }


Wizard Workflow

Standard Mobile Wizard Flow

1. User opens mobile count
2. Taps "Add Items" button
3. Mobile wizard opens
4. User selects filters:
   - Category: "Electronics"
   - Lot Type: "With Lot"
   - Qty Type: "Set To Zero"
5. Taps "Add Lines"
6. Wizard executes add_lines()
7. Lines added to count
8. User returns to count form
9. Begins scanning items

Common Use Cases

Use Case 1: Quick Category Add (Mobile)

# Add all products in a category to mobile count

# 1. Create mobile count
count_id = get_model("mobile.count").create({
    "location_id": warehouse_id,
    "date": time.strftime("%Y-%m-%d %H:%M:%S"),
    "memo": "Electronics Count"
})

# 2. Create wizard (transient)
wizard_id = get_model("stock.count.mobile.add").create({
    "stock_count_id": count_id,
    "categ_id": electronics_category_id,
    "lot_type": "with_lot",  # Electronics are usually serialized
    "qty_type": "reset",      # Blind count (zero start)
    "price_type": "product"   # Use product master cost
})

# 3. Execute wizard
result = get_model("stock.count.mobile.add").add_lines([wizard_id])

# 4. User can now scan electronics items
# Lines already created with zero quantities
# Each scan increments the count

Use Case 2: Mobile Lot-Tracked Items Only

# Mobile count of serialized items only

# User taps "Add Items" in mobile app
# Mobile wizard opens

wizard_data = {
    "stock_count_id": count_id,
    "lot_type": "with_lot",    # Only lot-tracked
    "qty_type": "previous",     # Show expected qty
    "price_type": "previous"
}

wizard_id = get_model("stock.count.mobile.add").create(wizard_data)
get_model("stock.count.mobile.add").add_lines([wizard_id])

# Result: Mobile count now has all lot-tracked items
# User scans each serial number to verify

Use Case 3: Mobile Blind Count Setup

# Setup for blind counting on mobile device

def setup_mobile_blind_count(location_id, category_id=None):
    """
    Setup mobile count for blind counting
    """
    # Create count
    count_id = get_model("mobile.count").create({
        "location_id": location_id,
        "date": time.strftime("%Y-%m-%d %H:%M:%S"),
        "memo": "Mobile Blind Count"
    })

    # Configure wizard for blind count
    wizard_config = {
        "stock_count_id": count_id,
        "qty_type": "reset",       # Start at zero (blind)
        "price_type": "product"
    }

    # Optionally filter by category
    if category_id:
        wizard_config["categ_id"] = category_id

    wizard_id = get_model("stock.count.mobile.add").create(wizard_config)
    get_model("stock.count.mobile.add").add_lines([wizard_id])

    return count_id

# Usage:
mobile_count_id = setup_mobile_blind_count(
    warehouse_id, 
    electronics_category_id
)
# Mobile user can now scan items

Use Case 4: Mobile Specific Product Count

# Mobile count for single product (all lots)

# User wants to count all units of a specific product
product_id = 123

# Create wizard for single product
wizard_id = get_model("stock.count.mobile.add").create({
    "stock_count_id": count_id,
    "product_id": product_id,    # Specific product only
    "lot_type": "with_lot",       # Product has lots
    "qty_type": "previous",
    "price_type": "previous"
})

get_model("stock.count.mobile.add").add_lines([wizard_id])

# Result: Count lines created for all lots of product 123
# Mobile user scans each lot individually

Use Case 5: Mobile UOM Filter

# Count items sold by specific unit (e.g., cases)

# Mobile count for items sold by "Case"
case_uom_id = get_model("uom").search([["name", "=", "Case"]])[0]

wizard_id = get_model("stock.count.mobile.add").create({
    "stock_count_id": count_id,
    "sale_invoice_uom_id": case_uom_id,  # Only items sold by case
    "qty_type": "previous",
    "price_type": "product"
})

get_model("stock.count.mobile.add").add_lines([wizard_id])

# Result: Mobile count has all items typically sold by case
# Useful for warehouse sections organized by unit type

Best Practices

1. Use Appropriate Qty Type for Mobile

# Good: Choose based on mobile counting method

# For BLIND counting (user sees nothing):
wizard_config = {
    "qty_type": "reset",  # Zero start - pure physical count
    "price_type": "product"
}

# For VERIFICATION counting (user checks expected):
wizard_config = {
    "qty_type": "previous",  # Show expected - verify or correct
    "price_type": "previous"
}

# Bad: Using previous qty for blind count
# (Biases the counter with expected values)

2. Filter Appropriately for Mobile Sections

# Good: Match wizard filters to physical layout

# Aisle A contains only lot-tracked electronics
wizard_electronics = {
    "categ_id": electronics_categ_id,
    "lot_type": "with_lot",
    "qty_type": "reset"
}

# Aisle B contains bulk non-tracked items
wizard_bulk = {
    "categ_id": supplies_categ_id,
    "lot_type": "without_lot",
    "qty_type": "previous"  # Verify bulk quantities
}

# Bad: Adding all products to mobile count
# (Mobile user overwhelmed with 1000+ items)

3. Pre-Configure for Mobile Users

# Good: Setup wizard defaults for mobile workflow

def create_mobile_count_wizard(count_id, scenario="blind"):
    """Create pre-configured wizard for mobile"""

    scenarios = {
        "blind": {
            "qty_type": "reset",
            "price_type": "product",
            "lot_type": None  # All items
        },
        "verify": {
            "qty_type": "previous",
            "price_type": "previous",
            "lot_type": None
        },
        "serialized": {
            "qty_type": "reset",
            "price_type": "product",
            "lot_type": "with_lot"
        }
    }

    config = scenarios.get(scenario, scenarios["blind"])
    config["stock_count_id"] = count_id

    wizard_id = get_model("stock.count.mobile.add").create(config)
    return wizard_id

# Usage: Pre-configured mobile wizards
wizard_id = create_mobile_count_wizard(count_id, "serialized")

4. Mobile UI Simplification

# Good: Simple mobile wizard UI

# Mobile wizard should show:
# - Simple dropdowns (not complex searches)
# - Clear labels ("Start at Zero" vs "reset")
# - Pre-selected common options
# - Large tap targets

# Example mobile-friendly defaults:
DEFAULT_MOBILE_CONFIG = {
    "qty_type": "reset",      # Most common for mobile
    "price_type": "product",  # Let system handle pricing
    "lot_type": None          # Don't filter unless necessary
}

Performance Considerations

Transient Model Benefits

# Transient models are automatically cleaned up
# No database bloat from temporary wizard data

# Wizard data lifecycle:
# 1. Created → Store in memory/temp table
# 2. Used → Execute add_lines()
# 3. Cleanup → Automatic removal

# No maintenance required!

Mobile Bandwidth Optimization

# Minimize data transfer for mobile

# Good: Pass minimal data to wizard
wizard_data = {
    "stock_count_id": count_id,  # Just the ID
    "categ_id": categ_id,         # Just the ID
    "qty_type": "reset"           # Simple string
}

# Bad: Passing full objects
# (Increases mobile data usage)

Troubleshooting

"Stock Count ID required"

Cause: Wizard created without target count.
Solution: Always specify stock_count_id:

wizard_id = get_model("stock.count.mobile.add").create({
    "stock_count_id": count_id,  # Required!
    "qty_type": "reset"
})

No Lines Added

Cause: Filters too restrictive, no products match.
Solution: Verify filter criteria:

# Check if products exist with criteria
products = get_model("product").search([
    ["type", "=", "stock"],
    ["categ_id", "=", categ_id],
    ["lot_tracking", "=", True]  # If lot_type="with_lot"
])
print(f"Products matching filter: {len(products)}")

Wizard Data Not Found

Cause: Transient wizard data expired or cleaned up.
Solution: Complete wizard in same session:

# Create and execute immediately
wizard_id = get_model("stock.count.mobile.add").create(wizard_data)
result = get_model("stock.count.mobile.add").add_lines([wizard_id])
# Don't store wizard_id for later use


Model Relationship Description
stock.count Many2One Target count for line addition
mobile.count Many2One Target mobile count
product Many2One Optional product filter
product.categ Many2One Optional category filter
uom Many2One Optional UOM filter

Mobile UI Integration

┌─────────────────────────┐
│   Add Items to Count    │
├─────────────────────────┤
│                         │
│ Category:               │
│ [Select Category ▼]     │
│                         │
│ Type:                   │
│ ○ All Items             │
│ ● Serialized Only       │
│ ○ Bulk Items Only       │
│                         │
│ Starting Quantity:      │
│ ● Start at Zero (Blind) │
│ ○ Show Expected Qty     │
│                         │
├─────────────────────────┤
│   [  ADD ITEMS  ]       │ ← Execute wizard
│   [   CANCEL   ]        │
└─────────────────────────┘

Version History

Last Updated: 2024-10-27
Model Version: stock_count_mobile_add.py
Framework: Netforce


Additional Resources

  • Mobile Count Documentation: mobile.count
  • Stock Count Documentation: stock.count
  • Stock Count Line Documentation: stock.count.line
  • Transient Model Guide

This documentation is generated for developer onboarding and reference purposes.