From 21e56e487ecb82cf0ee9e4c92652f2f873db0b3a Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 24 May 2016 16:35:34 +0200 Subject: [PATCH] [FIX] product_visible_discount: product without company_id When computing the real price of a product, a currency of reference is needed, first the currency of the product's company is privileged and if no company is set on the product then the currency of the user's company is taken. opw:678159 --- .../product_visible_discount/product_visible_discount.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index 6cb9b5440bf..48605841fb0 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -33,14 +33,15 @@ class sale_order_line(osv.osv): currency_id = item.pricelist_id.currency_id product = product_obj.browse(cr, uid, product_id, context=context) + product_currency = (product.company_id and product.company_id.currency_id) or self.pool['res.users'].browse(cr, uid, uid).company_id.currency_id if not currency_id: - currency_id = product.company_id.currency_id + currency_id = product_currency cur_factor = 1.0 else: - if currency_id.id == product.company_id.currency_id.id: + if currency_id.id == product_currency.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) + cur_factor = self.pool['res.currency']._get_conversion_rate(cr, uid, product_currency, currency_id, context=context) product_uom = context and context.get('uom') or product.uom_id.id if uom and uom != product_uom: