Skip to content
Snippets Groups Projects
Commit b6888282 authored by Christophe Simonis's avatar Christophe Simonis
Browse files

[FIX] account_edi: delay the computation of computed field


We need to wait the registry to be totally loaded to correctly recompute
the `edi_format_ids` field on all journals.

opw-3200644

closes odoo/odoo#117219

Signed-off-by: default avatarWilliam André (wan) <wan@odoo.com>
parent b262d4ee
Branches
Tags
No related merge requests found
......@@ -39,8 +39,14 @@ class AccountEdiFormat(models.Model):
edi_formats = super().create(vals_list)
# activate by default on journal
journals = self.env['account.journal'].search([])
journals._compute_edi_format_ids()
if not self.pool.loaded:
# The registry is not totally loaded. We cannot yet recompute the field on jourals as
# The helper methods aren't yet overwritten by all installed `l10n_` modules.
# Delay it in the register hook
self.pool._delay_compute_edi_format_ids = True
else:
journals = self.env['account.journal'].search([])
journals._compute_edi_format_ids()
# activate cron
if any(edi_format._needs_web_services() for edi_format in edi_formats):
......@@ -48,6 +54,14 @@ class AccountEdiFormat(models.Model):
return edi_formats
def _register_hook(self):
if hasattr(self.pool, "_delay_compute_edi_format_ids"):
del self.pool._delay_compute_edi_format_ids
journals = self.env['account.journal'].search([])
journals._compute_edi_format_ids()
return super()._register_hook()
####################################################
# Export method to override based on EDI Format
####################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment