From 8631d3cc648a0ea2852323a28aa775d495ee7e03 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 16 Apr 2019 12:29:55 +0000 Subject: [PATCH] [FIX] sale: _get_conversion_rate called with no date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Define two pricelists P1(€) the default one and P2($) with discount_policy = 'without_discount' - Activate P1 and P2 on the website - Go on the shop and select P2 Bug: An error was raised from function _get_conversion_rate because the arguments date and company_id were not defined because the function _get_real_price_currency was called from _website_product_id_change with the model "self.env['sale.order.line'] and not with a recordset. So the fields self.company_id and self.order_id.date_order were not defined. opw:1969849 closes odoo/odoo#32726 Signed-off-by: Simon Goffin (sig) --- addons/sale/models/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 6c698a35169..9a6b63a7d13 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -1578,7 +1578,7 @@ class SaleOrderLine(models.Model): if currency_id.id == product_currency.id: cur_factor = 1.0 else: - cur_factor = currency_id._get_conversion_rate(product_currency, currency_id, self.company_id, self.order_id.date_order) + cur_factor = currency_id._get_conversion_rate(product_currency, currency_id, self.company_id or self.env.user.company_id, self.order_id.date_order or fields.Date.today()) product_uom = self.env.context.get('uom') or product.uom_id.id if uom and uom.id != product_uom: