[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#117405 X-original-commit: b68882825aa917fc2cb64b6f083811398f7fa386 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
@@ -38,8 +38,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):
|
||||
@@ -47,6 +53,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
|
||||
####################################################
|
||||
|
||||
Reference in New Issue
Block a user