[FIX] purchase: fallabck to default currency

Steps to Reproduce Bug:

- Create PO
- Remove default Currency
- Add a Line

Bug:
```ValueError: Expected singleton: res.currency()```

With this Commit, we are using default currency to round amount.

closes odoo/odoo#74234

X-original-commit: d9ff2e8ec7200aa15830e92e5083251c4e81dd1c
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Swapnesh Shah
2021-07-26 11:55:12 +00:00
committed by GitHub
parent b9d157e7c6
commit 97521cc0b2
+3 -2
View File
@@ -31,9 +31,10 @@ class PurchaseOrder(models.Model):
line._compute_amount()
amount_untaxed += line.price_subtotal
amount_tax += line.price_tax
currency = order.currency_id or order.partner_id.property_purchase_currency_id or self.env.company.currency_id
order.update({
'amount_untaxed': order.currency_id.round(amount_untaxed),
'amount_tax': order.currency_id.round(amount_tax),
'amount_untaxed': currency.round(amount_untaxed),
'amount_tax': currency.round(amount_tax),
'amount_total': amount_untaxed + amount_tax,
})