From 5919fbb8a4a3bdf4e7122dadf419a131bad8d1f8 Mon Sep 17 00:00:00 2001
From: Swapnesh Shah <swapneshshah111@gmail.com>
Date: Wed, 8 Sep 2021 17:22:42 +0000
Subject: [PATCH] [FIX] account: use current date as fallback to convert
 currency

Description of the issue/feature this PR addresses: Fixes #76177

Current behavior before PR:
Before this commit, There will be tracback on adding new
Journal Item if there is not date on Journal Entry.

Desired behavior after PR is merged:
Now we use current date to as fallback to convert currency.

closes odoo/odoo#76178

Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
---
 addons/account/models/account_move.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index e047e2b85d7d..5c35df2c3c58 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -3693,7 +3693,7 @@ class AccountMoveLine(models.Model):
     def _onchange_amount_currency(self):
         for line in self:
             company = line.move_id.company_id
-            balance = line.currency_id._convert(line.amount_currency, company.currency_id, company, line.move_id.date)
+            balance = line.currency_id._convert(line.amount_currency, company.currency_id, company, line.move_id.date or fields.Date.context_today(line))
             line.debit = balance if balance > 0.0 else 0.0
             line.credit = -balance if balance < 0.0 else 0.0
 
-- 
GitLab