Skip to content

Custom Stock Count Line Documentation

Overview

The Custom Stock Count Line module (custom.stock.count.line) is identical to stock.count.line but registered for custom counting contexts. It represents individual count line records with product quantities, costs, and lot information. This model shares the same structure and functionality as the standard count line module.


Model Information

Model Name: custom.stock.count.line
Display Name: Custom Stock Count Line
Key Fields: None (detail records)

Features

  • ❌ No audit logging (parent audited)
  • ❌ No multi-company (inherits)
  • ✅ Cascade delete with parent
  • ✅ Computed cost fields
  • ✅ Lot/serial tracking
  • ✅ Identical to stock.count.line

Key Fields Reference

Essential Fields

Field Type Description
count_id Many2One Parent stock count (cascade)
product_id Many2One Product being counted
lot_id Many2One Lot/serial number
prev_qty Decimal System quantity (readonly)
new_qty Decimal Physical count
uom_id Many2One Unit of measure

Cost Fields

Field Type Description
prev_cost_price Decimal Previous cost/unit (computed)
prev_cost_amount Decimal Previous total cost
unit_price Decimal New cost/unit
new_cost_amount Decimal New total cost (computed)

Supporting Fields

Field Type Description
bin_location Char Warehouse bin (readonly)
lot_weight Decimal Weight from lot (computed)
cyclecount_id Many2One Cycle count link

Computed Fields

get_prev_cost_price(ids, context)

Calculates previous average cost per unit.

Formula: prev_cost_amount / prev_qty

get_new_cost_amount(ids, context)

Calculates new total cost.

Formula: round(new_qty × unit_price, 2)


Usage

This model is used identically to stock.count.line. See Stock Count Line Documentation for: - Complete field reference - API methods - Use cases - Best practices


Common Use Cases

Use Case 1: Create Custom Count Line

# Same as stock.count.line

line_id = get_model("custom.stock.count.line").create({
    "count_id": count_id,
    "product_id": product_id,
    "lot_id": lot_id,
    "prev_qty": 50,
    "new_qty": 48,
    "unit_price": 12.50,
    "uom_id": 1
})

Use Case 2: Update Quantity

line = get_model("custom.stock.count.line").browse(line_id)
line.write({"new_qty": 47})

Use Case 3: Variance Analysis

lines = get_model("custom.stock.count.line").search_browse([
    ["count_id", "=", count_id]
])

for line in lines:
    variance = line.new_qty - line.prev_qty
    if variance != 0:
        print(f"{line.product_id.code}: {variance:+.2f}")

Model Relationship Description
stock.count Many2One Parent count
product Many2One Product
stock.lot Many2One Lot/serial
uom Many2One Unit of measure
cycle.stock.count Many2One Cycle count

Version History

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


Additional Resources

  • Stock Count Line Documentation: stock.count.line (complete reference)
  • Custom Stock Count Session Documentation: custom.stock.count.session
  • Stock Count Documentation: stock.count

This documentation is generated for developer onboarding and reference purposes.