From b044a6be8df8a5238ae70d09c94229bf6e62318f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 14 Jun 2019 08:28:13 +0000 Subject: [PATCH] [FIX] sale: no company - Activate multi-company - In a SO, remove the company (the field is not mandatory) The currency rate computation crashes. The computation expects a company in order to compute the rate. If there is no company set, we set the rate to 1.0. It is worth stressing that if both multi-company and multi-currency are activated, a company is necessary for reporting consistency. Fixes #34066 opw-2009044 closes odoo/odoo#34120 Signed-off-by: Nicolas Martinelli (nim) --- addons/sale/models/sale.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 1d4abad0c7b..08e1c8d4b08 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -217,6 +217,8 @@ class SaleOrder(models.Model): @api.depends('pricelist_id', 'date_order', 'company_id') def _compute_currency_rate(self): for order in self: + if not order.company_id: + order.currency_rate = 1.0 order.currency_rate = self.env['res.currency']._get_conversion_rate(order.company_id.currency_id, order.currency_id, order.company_id, order.date_order) def _compute_access_url(self):