OdooWiki OCA HUB

Sale Margin Pricelist Computation

sale_margin_pricelist_computation folder_open OCA/margin-analysis open_in_new
Sale License: AGPL-3

This module allows the use of formulas to calculate the margin of sale order lines.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Lets you write small Python formulas on a pricelist rule to define how the cost price and the sale price used for margin are calculated on sale order lines.

This module extends the margin feature of sales. On each pricelist rule (product.pricelist.item) you get a new "Margin's Formulas" section with two code fields: one for the cost price and one for the sale price used when computing the margin.

  • The cost price formula replaces the normal product cost for margin purposes on sale order lines that use that pricelist rule.
  • The sale price formula replaces the line price used to compute the margin amount and margin percentage.
  • Formulas are written in Python and can use variables such as the order line, the product, its standard price and list price, the pricelist, the pricelist rule, the user, the environment and a float comparison helper. The result is returned by assigning a value to result.
  • When you save a pricelist rule, the formulas are tested automatically; if a formula is invalid, Odoo shows a validation error and refuses to save.
  • The formulas are evaluated on sale.order.line when the margin, the purchase price, the ordered quantity or the delivered quantity change, so margins stay up to date.
  • The new fields appear on the pricelist rule form, in the same screen where you configure prices and discounts.

Depends on

sale_margin
Models and fields (2)
  • sale.order.line · extends an existing model
  • product.pricelist.item · extends an existing modelmargin_cost_price_formula, margin_sale_price_formula

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: 1 confirmed, 8 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

OCA documentation · Odoo 18.0
  • Go to Sales > Products > Pricelists and select one or create a new one.
  • Add a new Price Rule or select an existing one.
  • Fill in the fields Margin Cost Price Formula and/or Margin Sale Price Formula.
  • Create a new Sales Order and set the previously created pricelist.
  • You will see that the margin is calculated using the formulas from the pricelist.

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.