From 956204fe105919c5346e4eca95fa24b7e10ef9be Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Wed, 17 Jul 2019 04:57:49 +0000 Subject: [PATCH] [FIX] sale: do not crash on _compute_currency_rate if any currency is not defined yet The _get_conversion_rate method crashes if any of its parameters is undefined. Therefore triggering the compute of the currency_rate early* causes it to crash. (* e.g. by putting it in the view with studio) opw 2035604 closes odoo/odoo#34928 Signed-off-by: Nans Lefebvre (len) --- addons/sale/models/sale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 2efa2c7d919..4cb02549b38 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -220,7 +220,10 @@ class SaleOrder(models.Model): if not order.company_id: order.currency_rate = order.currency_id.with_context(date=order.date_order).rate or 1.0 continue - order.currency_rate = self.env['res.currency']._get_conversion_rate(order.company_id.currency_id, order.currency_id, order.company_id, order.date_order) + elif order.company_id.currency_id and order.currency_id: # the following crashes if any one is undefined + order.currency_rate = self.env['res.currency']._get_conversion_rate(order.company_id.currency_id, order.currency_id, order.company_id, order.date_order) + else: + order.currency_rate = 1.0 def _compute_access_url(self): super(SaleOrder, self)._compute_access_url()