From a90b94f29158ced860a60e0cef1e85edcafbb203 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Sun, 26 Apr 2015 10:58:03 +0200 Subject: [PATCH] [FIX] sale_margin: product margin The product margin computed on each line of a sale order must be rounded according to the currency of the order pricelist. Inspired from the field 'price_subtotal' in addons/sale/sale.py --- addons/sale_margin/sale_margin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index 9744d84934a..f1d2e7652ce 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -49,11 +49,14 @@ class sale_order_line(osv.osv): return res def _product_margin(self, cr, uid, ids, field_name, arg, context=None): + cur_obj = self.pool.get('res.currency') res = {} for line in self.browse(cr, uid, ids, context=context): + cur = line.order_id.pricelist_id.currency_id res[line.id] = 0 if line.product_id: - res[line.id] = line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty) + tmp_margin = line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty) + res[line.id] = cur_obj.round(cr, uid, cur, tmp_margin) return res _columns = {