From 7d2ddf23adea66f5a25a349ac81bd4ec039cb26c Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Wed, 5 Oct 2022 12:09:43 +0000 Subject: [PATCH] [FIX] account_edi: fix _compute_edi_format_ids on journal When computing the edi_formats on a journal, keep the ones that are already checked (if they are compatible with this journal). The bug occurs when migrating a DB: if a new edi_format is created, the `create` will call the `_compute_edi_format_ids` on all journals. Thus, all edi_formats will be reset since nothing keeps track of the already checked edi_formats. This PR fixes this. closes odoo/odoo#102368 X-original-commit: 166aaeef1ca69399581714b61ea77db7c3e04f31 Signed-off-by: Laurent Smet Signed-off-by: Julien Van Roy --- addons/account_edi/models/account_journal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account_edi/models/account_journal.py b/addons/account_edi/models/account_journal.py index 8c199e48d4c..be5d975d79f 100644 --- a/addons/account_edi/models/account_journal.py +++ b/addons/account_edi/models/account_journal.py @@ -73,7 +73,8 @@ class AccountJournal(models.Model): for journal in self: enabled_edi_formats = edi_formats.filtered(lambda e: e._is_compatible_with_journal(journal) and - e._is_enabled_by_default_on_journal(journal)) + (e._is_enabled_by_default_on_journal(journal) + or (e in journal.edi_format_ids))) # The existing edi formats that are already in use so we can't remove it. protected_edi_format_ids = protected_edi_formats_per_journal.get(journal.id, set())