Stock Account Product Run FIFO Hook
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
Know which outgoing move consumes each FIFO candidate
In Odoo 20, the per-quantity FIFO computation moved from _run_fifo() to _get_fifo_value() (_run_fifo() now values whole products in batch), so the hook is injected in _get_fifo_value(). Core no longer passes the outgoing move being valued, so this module also patches stock.move._set_value() to put it in the valued_move context key.
Odoo 20 also replays the FIFO valuation (_run_fifo(correction=True)) when a valued move line quantity, location or lot is edited, a move date changes, a product value is adjusted, the costing method changes, or a receipt fills stock that was already sold. This module patches it to call the same hook for each candidate consumed during the replay, and adds _run_fifo_correction_reset() before it so that custom modules can drop the data stored for the outgoing moves that are replayed.
Table of contents
Usage
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) — 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: The stock move being valued that is consuming this candidate (None when core estimates a FIFO price without valuing a move)
Use it to capture exact qty/value taken, create usage records, or track valuation relationships between moves.
When valued_move is Passed to Context
This module sets valued_move when stock.move._set_value() values an outgoing FIFO move, keeping the core batch valuation of all the moves.
The hook is called:
after the outgoing move is done (moves are valued after _action_done())
once per move line for lot valuated products, with the quantity and value of the lot
when core estimates a FIFO price without valuing a move (e.g. COGS of an invoice without stock moves, PoS), with valued_move set to None: check it before storing anything
The quantity valued beyond the available candidates (negative stock) does not call the hook. When a later receipt fills that shortage, the FIFO replay calls the hook with the receipt as candidate.
FIFO replay
Before replaying the FIFO valuation, _correct_inventory_valuation() calls _run_fifo_correction_reset(valued_moves) with the outgoing moves whose value is recomputed. Override it to drop the data stored for those moves: the replay calls _run_fifo_prepare_candidate_update() again for each of them.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
Forgeflow (https://www.forgeflow.com)
Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
Jasmin Solanki <jasmin.solanki@forgeflow.com>
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
This module is part of the OCA/stock-logistics-workflow project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Metadata
Release files for odoo-addon-stock-account-product-run-fifo-hook 20.0.1.0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| odoo_addon_stock_account_product_run_fifo_hook-20.0.1.0.0.4-py3-none-any.whl | Python 3 | none | any | Details for odoo_addon_stock_account_product_run_fifo_hook-20.0.1.0.0.4-py3-none-any.whl |
Release files / odoo_addon_stock_account_product_run_fifo_hook-20.0.1.0.0.4-py3-none-any.whl
| Download URL | odoo_addon_stock_account_product_run_fifo_hook-20.0.1.0.0.4-py3-none-any.whl |
|---|---|
| Size | 37.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26e70182c0925c995d8b5cc7ef17f414f992a48e25fd4f942d77c08f1f3c034e
|
|
BLAKE2b-256 checksum How to use checksums |
12dd2201903d5ee3f73e192ccc787b6efd5331adb25d970f0925ef197124adbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for odoo-addon-stock-account-product-run-fifo-hook 20.0.1.0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.