Recompute sale margin when related stock move cost price is changed.
auto_awesome What this module does
AI-generated from the code · Odoo 18.0Keeps the cost used for sale margin up to date: when the cost recorded on a stock valuation entry changes, the linked sales order line's cost is updated automatically so margins stay correct.
This module links stock valuation entries to sales order lines and refreshes the cost used to calculate margin.
- When a new stock valuation entry is created for a stock move that comes from a sales order line, the module immediately recalculates the cost on that sales order line.
- When the unit cost of an existing stock valuation entry is modified, the same recalculation is triggered.
- Only outgoing stock movements (negative quantities) are synchronised, so customer deliveries drive the cost update.
- If the unit of measure of the valuation entry differs from the unit of measure on the sales order line, the cost is converted before being written.
- The recalculated value is stored as the purchase price on the sales order line, which is the field used by the margin calculation.
- A technical flag allows other processes to skip this synchronisation when needed.
It touches the stock.valuation.layer model and works together with the sale margin and sale stock features. There are no new menus or screens: the change happens silently in the background on sales order lines.
Depends on
Models and fields (1)
- stock.valuation.layer · extends an existing model
Text generated by AI (DeepSeek) from reading the Odoo 18.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-03Confirmation status: 6 confirmed, 3 with no information of 9 versions.
Sources · Odoo 18.0
Confirmed on 2026-11-03 in branch 18.0 of OCA/margin-analysis.
terminal Installation and usage
No verified informationInstallation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
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.