[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 <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2022-10-06 17:00:27 +02:00
parent abfc535a1f
commit 7d2ddf23ad
+2 -1
View File
@@ -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())