From 8de70d07ba150b33575058e9e98a3b0f53bbf429 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 22 Feb 2016 11:29:55 +0100 Subject: [PATCH] [FIX] product_visible_discount: Show Discount not working with multi-currencies pricelist The sale price set on the product is in the currency of the company. opw:669918 --- .../product_visible_discount.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index 98363e6ff42..7ebaf2f0636 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -30,16 +30,25 @@ class sale_order_line(osv.osv): item = item_obj.browse(cr, uid, rule_id, context=context) if item.base == 'standard_price': field_name = 'standard_price' - currency_id = item.pricelist_id.currency_id.id + currency_id = item.pricelist_id.currency_id product = product_obj.browse(cr, uid, product_id, context=context) if not currency_id: - currency_id = product.company_id.currency_id.id - factor = 1.0 + currency_id = product.company_id.currency_id + cur_factor = 1.0 + else: + if currency_id.id == product.company_id.currency_id.id: + cur_factor = 1.0 + else: + cur_factor = self.pool['res.currency']._get_conversion_rate(cr, uid, product.company_id.currency_id, currency_id, context=context) + if uom and uom != product.uom_id.id: # the unit price is in a different uom - factor = self.pool['product.uom']._compute_price(cr, uid, uom, 1.0, product.uom_id.id) - return product[field_name] * factor, currency_id + uom_factor = self.pool['product.uom']._compute_price(cr, uid, uom, 1.0, product.uom_id.id) + else: + uom_factor = 1.0 + + return product[field_name] * uom_factor * cur_factor, currency_id.id @api.multi @api.onchange('product_id')