From f115f330f9b092bd881839eda359f8998219fa19 Mon Sep 17 00:00:00 2001 From: paso-odoo Date: Thu, 25 May 2023 06:30:04 +0000 Subject: [PATCH] [FIX] account: fix TypeError for currency in journal items If applied, this commit will solve the issue of unsupported operand type in journal item(s) when currency is not set. Steps to produce: - Accounting > Journal Entries > Create new entry. - Add a line in Journal Items and remove the currency from that line. - Save > Error will be generated. Fix this issue by calling the compute of the currency when the currency is not available. sentry - 4069681536 closes odoo/odoo#125661 X-original-commit: 7163134b397e113c10936af908bdfebef2336d67 Signed-off-by: Florian Gilbert (flg) Signed-off-by: Parth Solanki (paso) --- addons/account/models/account_move_line.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 90e5e1858b0..1944f7af7b5 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -634,12 +634,15 @@ class AccountMoveLine(models.Model): date=date, ) for line in self: - line.currency_rate = get_rate( - from_currency=line.company_currency_id, - to_currency=line.currency_id, - company=line.company_id, - date=line.move_id.invoice_date or line.move_id.date or fields.Date.context_today(line), - ) + if line.currency_id: + line.currency_rate = get_rate( + from_currency=line.company_currency_id, + to_currency=line.currency_id, + company=line.company_id, + date=line.move_id.invoice_date or line.move_id.date or fields.Date.context_today(line), + ) + else: + line.currency_rate = 1 @api.depends('currency_id', 'company_currency_id') def _compute_same_currency(self):