From ddd7772abc94a7b074b10f23eb96c647d3860971 Mon Sep 17 00:00:00 2001 From: Elias Regopoulos Date: Fri, 14 Jul 2023 18:15:21 +0000 Subject: [PATCH] [FIX] account: Instantiate potentially empty variable If `journal_data` does not have a 'code' key, then the `journal` variable never gets assigned and any references to it throw an "UnboundLocalError: local variable 'journal' referenced before assignment" We avoid this by assigning to journal an initial value of None. closes odoo/odoo#129542 X-original-commit: b9cbb96c1ded18deb344cbf578083e6a0e9a353e Signed-off-by: Florian Gilbert (flg) --- addons/account/models/chart_template.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 099f474f0d4..b103d4afb0b 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -226,6 +226,7 @@ class AccountChartTemplate(models.AbstractModel): if self.ref(xmlid, raise_if_not_found=False): del data['account.journal'][xmlid] else: + journal = None if 'code' in journal_data: journal = self.env['account.journal'].with_context(active_test=False).search([ *self.env['account.journal']._check_company_domain(company),