OdooWiki OCA HUB

Sale margin sync

sale_margin_sync folder_open OCA/margin-analysis open_in_new
Sales License: AGPL-3

Recompute sale margin when related stock move cost price is changed.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Keeps 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

sale_marginsale_stock
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-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 6 confirmed, 3 with no information of 9 versions.

Sources · Odoo 16.0

Confirmed on 2026-11-03 in branch 16.0 of OCA/margin-analysis.

terminal Installation and usage

No verified information

Installation 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.

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.