Skip to content
Snippets Groups Projects
Commit 0b586677 authored by Josse Colpaert's avatar Josse Colpaert Committed by Goffin Simon
Browse files

[FIX] sale_margin: Error in Margin calculation

If cost(purchase_price) was 0, margin calculation was incorrect.
The function _product_margin didn't consider the use case
where the cost of the product was set to 0 on the line.

So before the fix it fallback on standard price instead of considering  a cost of 0.

opw:1890452, 1885587
parent 9b16af6a
Branches
Tags
No related merge requests found
......@@ -60,10 +60,6 @@ class SaleOrderLine(models.Model):
for line in self:
currency = line.order_id.pricelist_id.currency_id
price = line.purchase_price
if not price:
from_cur = line.env.user.company_id.currency_id.with_context(date=line.order_id.date_order)
price = from_cur.compute(line.product_id.standard_price, currency, round=False)
line.margin = currency.round(line.price_subtotal - (price * line.product_uom_qty))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment