From dc3fe1e07e486dde2593c4a479d0b3c09effc791 Mon Sep 17 00:00:00 2001 From: Atul Patel Date: Tue, 6 Jun 2023 08:15:29 +0000 Subject: [PATCH] [FIX] account: fix duplicate constraint for journal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During upgrading the chart template will try to create xmlid to existing records to avoid duplicate journal codes. but there are some existing code journal which was inactive and it was not unlinked so need to search for archived journal too. ``` psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "account_journal_code_company_uniq" DETAIL: Key (company_id, code)=(1, EXCH) already exists. ``` closes odoo/odoo#124022 X-original-commit: 7264e664f5a665cea3cd4e9d4f40214c51442080 Signed-off-by: William André (wan) --- addons/account/models/chart_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index ffa160d78fc..36e86325eaf 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -219,7 +219,7 @@ class AccountChartTemplate(models.AbstractModel): if self.ref(xmlid, raise_if_not_found=False): del data['account.journal'][xmlid] elif 'code' in journal_data: - journal = self.env['account.journal'].search([ + journal = self.env['account.journal'].with_context(active_test=False).search([ ('code', '=', journal_data['code']), ('company_id', '=', company.id), ])