Skip to content

CookiesWe use the cookies the site needs to work. Analytics and marketing only turn on with your permission. Privacy policy

My choices
What stays on

Your choice lasts 12 months. To change it, open “Cookies” in the footer.

IntData
IntData · https://intdata.com.br/en/metrics/gross-margin-by-product · November 30, 2026

Gross margin by product

How much is left from each product, brand or category after cost?

Verified Metric version 1.3.0

What it is

Net revenue of each product in the period (the lines of posted customer invoices and of point-of-sale orders without an invoice, before taxes, minus returns) minus the cost (quantity sold × the product's cost on record). The margin percentage is margin ÷ revenue. A product with zero cost on record comes in with the cost of its latest vendor bill, and the result is marked as an estimate; a product with neither a cost on record nor a purchase stays out of the total and is listed in an alert.

What it is not

  • It is not the margin at the cost at the time of sale: it uses today's cost on record (product.standard_price). A cost that changed a lot in the period distorts it.
  • It is not contribution margin: it does not take out commission, freight, card fees or sales taxes.
  • It does not include products with no cost on record and no purchase posted: they would show a 100% margin, which is missing data, not profit. With a purchase, they come in at its cost, marked as an estimate.
  • It does not include services (freight, fees): they stay out, as in the ABC curve.

Pitfalls this metric handles

The traps a hasty calculation falls into — and how this metric avoids each one.

Zero cost

The mistake
A product sold with standard_price = 0 comes in with a 100% margin.
Why it happens
It is missing data, and it inflates the margin of the whole group.
How we handle it
Use the cost of the product's latest vendor bill, marked as an estimate; with no purchase, take it out of the total (revenue and cost) and list the products with each one's revenue. If nothing is left, say it cannot be calculated instead of showing zero.
Evidence from a real database
On a real database (Oct 24, 2026), 140 products with zero standard_price carried BRL 16,703.57 of valuation: zero cost is common, not an exception.

Point-of-sale order with an invoice

The mistake
Adding the point-of-sale order line and the line of the invoice it generated.
Why it happens
The product's revenue and cost would count twice.
How we handle it
The net sales rule: an order with an invoice counts through the invoice.

Return

The mistake
Adding the returned quantity as a sale.
Why it happens
The returned product would gain revenue and cost instead of losing them.
How we handle it
The return line comes in with negative quantity and revenue.

Service as a product

The mistake
Freight and fees come in as products with zero cost.
Why it happens
A 100% margin on an item that is not merchandise.
How we handle it
Leave out products of type service.

Where the number comes from

Audit trail

Odoo model
account.move.line + pos.order.line + product.product
Fields
account.move.line.balance, account.move.line.quantity, account.move.line.date, account.move.move_type, pos.order.line.price_subtotal, pos.order.line.qty, product.product.standard_price, product.product.categ_id
Why this path
Revenue per product only exists on the lines: the invoice's and the till's. The documents are the same as net sales, so total revenue matches it (minus services).

How you can adjust it

ParameterWhat it doesOptions
Companies company ids, always explicit —
Period {from, to} in local dates or relative; without a period, the last 90 days —
Filters narrow down by products or categories (lists of ids) products and categories
Group by the table row product, brand, and category
Sort by row order margin, margin percentage, and revenue
Items listed how many rows to list; the total always covers the whole set —

Validation

To be validated on a real database. The method comes from a script that already ran in a customer's operation, and the calculation passes the automated tests against the demo database. IntData has not yet checked it on a real database; until then, check the first result in Odoo using the path in the audit trail.

Date
October 25, 2026
Checked against
The demo database: revenue plus the zero-cost revenue matches net sales without services, and the test Odoo servers. To be validated on a real database.
Expected Odoo versions
14.0, 16.0, 17.0, 18.0, 19.0, 20.0
Note
Without point of sale, invoices only. With OCA l10n-brazil, the lines come from the fiscal document. The cost is the one on record, which in Odoo is per company. Does not use read_group.

Need a variation of this metric, or another one that does not exist yet?