OdooWiki OCA HUB

Stock Account Product Run FIFO Hook

stock_account_product_run_fifo_hook folder_open OCA/stock-logistics-workflow open_in_new
Warehouse Management License: LGPL-3

This module adds hook points in the FIFO valuation process to add more flexibility in the information that is stored and processed during FIFO candidate calculations.

In Odoo 19, the valuation logic has shifted from stock.valuation.layer to stock.move. This module provides extension points for custom modules to:

  • Access FIFO candidate move information during valuation
  • Enrich stock moves with custom candidate data
  • Control standard price update logic during FIFO operations

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Adds extension points to the FIFO stock valuation process so other modules can enrich the data stored on stock moves during valuation. It does not add any screen or menu on its own.

This is a technical foundation module for Odoo's FIFO (first in, first out) inventory valuation. It does not add menus, buttons, reports or settings that a user can click; instead it changes how the FIFO cost calculation runs behind the scenes.

When Odoo values an outgoing stock move using FIFO, it walks through the oldest incoming moves (the FIFO stack) and takes value from them. This module wraps that calculation and, for each candidate move it consumes, calls a preparation step (_run_fifo_prepare_candidate_update) on product.product. In the base module that step does nothing, but other modules can override it to record extra information on the stock move being valued, such as custom candidate data.

The module also keeps the original FIFO method available as _run_fifo_original, so the standard behaviour is preserved when no extension is installed. It handles negative quantities by returning the quantity multiplied by the standard price (or the price at a given date), and it deals with partial quantities, lots and valuation at a specific date.

In short: it touches product.product and the stock move valuation flow from stock_account, and gives developers a safe hook to customise FIFO valuation without rewriting the whole method. End users see no new screens; the effect only appears through modules that use this hook.

Depends on

stock_account

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 7 confirmed, 2 with no information of 9 versions.

Sources · Odoo 14.0

Confirmed on 2026-11-03 in branch 14.0 of OCA/stock-logistics-workflow.

terminal Installation and usage

OCA documentation · Odoo 19.0
  • Add dependency of this module to your custom module:
"depends": ["stock_account_product_run_fifo_hook"],
  • Inherit from product.product in your custom module
  • Override the hook methods to add custom logic:
  • _run_fifo_prepare_candidate_update(candidate_move, qty_taken, value_taken, valued_move=None) — Called for each FIFO candidate when it is consumed.
  • candidate_move: The FIFO source move being consumed
  • qty_taken: Quantity consumed from this candidate
  • value_taken: Value consumed from this candidate
  • valued_move: (obtained via context) The stock move being valued that is consuming this candidate Use it to capture exact qty/value taken, create usage records, or track valuation relationships between moves.

When valued_move is Passed to Context

The valued_move is passed to context when an outgoing stock move calls _set_value() for FIFO costing:

# In stock.move._set_value() for FIFO moves:
for move in fifo_moves:
    super(StockMove, move.with_context(valued_move=move))._set_value(
        correction_quantity=correction_quantity
    )

This happens when:

  • An outgoing stock move (customer delivery, internal transfer, etc.) is being valued
  • The product uses FIFO costing method
  • The system needs to consume FIFO candidates to determine the move's valuation

During this process:

  • _run_fifo() is called to calculate the unit cost
  • For each FIFO candidate consumed, _run_fifo_prepare_candidate_update() hook is called
  • The valued_move (the move being valued) is available in context
  • You can use it to link the candidate to the move being valued

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.