From cc7d9a6032082fa32949c8cf0bdec2c1f7eb9b6f Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Wed, 25 Mar 2020 10:49:57 +0000 Subject: [PATCH] [FIX] account: no recompute when currency_id is unset When the currency_id is unset from the invoice and account moves are set, by means of updating taxes or the line itself, since there are no checks on the actual presence of a currency, currency methods will invoked causing crashes. Imposing the condition directly on top of the onchange solves the issue. Since the currency_id is a required field for the invoice the recomputation will be triggered again with the correct values. opw-2192628 closes odoo/odoo#48458 X-original-commit: f795b1bc7b42bdcbd4bd9895616461d2702f1e41 Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account_move.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 9f3c2abacef..c21df95feaa 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -348,6 +348,8 @@ class AccountMove(models.Model): @api.onchange('date', 'currency_id') def _onchange_currency(self): + if not self.currency_id: + return if self.is_invoice(include_receipts=True): company_currency = self.company_id.currency_id has_foreign_currency = self.currency_id and self.currency_id != company_currency