Permalink
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
  • Loading branch information...
jco-odoo authored and simongoffin committed Oct 16, 2018
1 parent 9b16af6 commit 0b586677e23a4460d781b45355562b7ca29d3f11
Showing with 0 additions and 4 deletions.
  1. +0 −4 addons/sale_margin/models/sale_order.py
@@ -60,10 +60,6 @@ def _product_margin(self):
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 comments on commit 0b58667

Please sign in to comment.