From d944a652dc73b0c9af4bb0a1672415320aabfef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 22 Jan 2014 13:00:42 +0100 Subject: [PATCH] [FIX] product: when computing lst_price, that is the public price computed based on the template price + margin and extra, use the pricelist currency if a pricelist has been given. This alows for example to have 'promo' prices on the ecommerce that are in the same currency. bzr revid: tde@openerp.com-20140122120042-ovh2mi70q0beeqwq --- addons/product/product.py | 17 +++++++++++++---- addons/website_sale/views/website_sale.xml | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 163785459b4..50a7192458c 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -554,10 +554,15 @@ class product_product(osv.osv): _product_incoming_qty = _get_product_available_func(('confirmed','waiting','assigned'), ('in',)) def _product_lst_price(self, cr, uid, ids, name, arg, context=None): - res = {} + res = dict.fromkeys(ids, 0.0) product_uom_obj = self.pool.get('product.uom') - for id in ids: - res.setdefault(id, 0.0) + + # retrieve pricelist + pricelist = None + if context.get('pricelist'): + pricelist = self.pool['product.pricelist'].browse(cr, uid, context.get('pricelist'), context=context) + base_currency = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id + for product in self.browse(cr, uid, ids, context=context): if 'uom' in context: uom = product.uos_id or product.uom_id @@ -565,7 +570,11 @@ class product_product(osv.osv): uom.id, product.list_price, context['uom']) else: res[product.id] = product.list_price - res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra + res[product.id] = (res[product.id] or 0.0) * (product.price_margin or 1.0) + product.price_extra + # update the result, according to the eventual pricelist currency + if pricelist and pricelist.currency_id: + res[product.id] = self.pool['res.currency'].compute( + cr, uid, base_currency.id, pricelist.currency_id.id, res[product.id], round=False, context=context) return res def _save_product_lst_price(self, cr, uid, product_id, field_name, field_value, arg, context=None): diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 7a2920583b8..2c08a48cc7d 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -62,7 +62,7 @@
- +