[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) <flg@odoo.com>
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user