diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2019-06-27 09:37:22 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2019-06-27 09:37:22 +0000 |
| commit | 365110e9ebe8bcb9eb08e44ec961defee8c2ac82 (patch) | |
| tree | 134cd54783b4d69d452513a83354792652e86b84 | |
| parent | 6387614dca1b001d0d4baddaf969505e52576dec (diff) | |
[FIX] sale: no company
Avoid crash at currency conversion when no company is set on the SO
opw-2009044
closes odoo/odoo#34408
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | addons/sale/models/sale.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index b6f861d9af3..2efa2c7d919 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -1459,7 +1459,7 @@ class SaleOrderLine(models.Model): if currency != self.order_id.pricelist_id.currency_id: base_price = currency._convert( base_price, self.order_id.pricelist_id.currency_id, - self.order_id.company_id, self.order_id.date_order or fields.Date.today()) + self.order_id.company_id or self.env.user.company_id, self.order_id.date_order or fields.Date.today()) # negative discounts (= surcharge) are included in the display price return max(base_price, final_price) @@ -1642,7 +1642,7 @@ class SaleOrderLine(models.Model): # we need new_list_price in the same currency as price, which is in the SO's pricelist's currency new_list_price = currency._convert( new_list_price, self.order_id.pricelist_id.currency_id, - self.order_id.company_id, self.order_id.date_order or fields.Date.today()) + self.order_id.company_id or self.env.user.company_id, self.order_id.date_order or fields.Date.today()) discount = (new_list_price - price) / new_list_price * 100 if (discount > 0 and new_list_price > 0) or (discount < 0 and new_list_price < 0): self.discount = discount |
