From 79787084ffe66001203e7a593d121f5c0e287779 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 27 Oct 2014 18:02:59 +0100 Subject: [PATCH] [FIX] sale_margin: cost price uom When computing the cost price to display, take the uom into account. The cost of 1 Unit or 1 dozen should not be the same. opw 599727 --- addons/sale_margin/sale_margin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index 72d252a7c11..7c58028658e 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -36,7 +36,11 @@ class sale_order_line(osv.osv): frm_cur = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id to_cur = self.pool.get('product.pricelist').browse(cr, uid, [pricelist])[0].currency_id.id if product: - purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price + product = self.pool['product.product'].browse(cr, uid, product, context=context) + purchase_price = product.standard_price + to_uom = res.get('product_uom', uom) + if to_uom != product.uom_id.id: + purchase_price = self.pool['product.uom']._compute_price(cr, uid, product.uom_id.id, purchase_price, to_uom) ctx = context.copy() ctx['date'] = date_order price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False, context=ctx)