Skip to content

Commit

Permalink
[FIX] sale: no company
Browse files Browse the repository at this point in the history
Avoid crash at currency conversion when no company is set on the SO

opw-2009044

closes odoo#34408

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
nim-odoo committed Jun 27, 2019
1 parent 6387614 commit 365110e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/sale/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ def _get_display_price(self, product):
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)

Expand Down Expand Up @@ -1642,7 +1642,7 @@ def _onchange_discount(self):
# 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
Expand Down

0 comments on commit 365110e

Please sign in to comment.