From 97521cc0b2dd9f7e6c00a917769aad1d4fa356c7 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sun, 25 Jul 2021 16:50:28 +0000 Subject: [PATCH] [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 --- addons/purchase/models/purchase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 68f1560f055..2c26d013745 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -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, })