[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) <len@odoo.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user