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