diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2019-06-14 08:28:13 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2019-06-14 08:33:04 +0000 |
| commit | b044a6be8df8a5238ae70d09c94229bf6e62318f (patch) | |
| tree | 41cce84b0c65e78d3c3bed591695be30b4ddb713 | |
| parent | 4870251f0b0b0503b526b367827ac186ae1fbefd (diff) | |
[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) <nim@odoo.com>
| -rw-r--r-- | addons/sale/models/sale.py | 2 |
1 files changed, 2 insertions, 0 deletions
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): |
