From ac7e0795beeb668b5552550abd53bc536d04586e Mon Sep 17 00:00:00 2001 From: "Paolo Gatti (pgi)" Date: Fri, 15 Mar 2024 19:37:38 +0100 Subject: [PATCH] [IMP] account: Compute the template function only once When making a registry of all available chart templates from exisiting modules, the templating function is executed 5 times per Chart template instead of once. It may not be all this relevant, but the fix is very basic. related PR: odoo/odoo#148370 task-3607459 Part-of: odoo/odoo#157918 --- addons/account/models/ir_module.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/account/models/ir_module.py b/addons/account/models/ir_module.py index 8592b7e0bbc..efae5f7d189 100644 --- a/addons/account/models/ir_module.py +++ b/addons/account/models/ir_module.py @@ -39,17 +39,18 @@ class IrModule(models.Model): else: templates = { fct._l10n_template[0]: { - 'name': fct(ChartTemplate).get('name'), - 'parent': fct(ChartTemplate).get('parent'), - 'sequence': fct(ChartTemplate).get('sequence', 1), - 'country': fct(ChartTemplate).get('country', ''), - 'visible': fct(ChartTemplate).get('visible', True), + 'name': template_values.get('name'), + 'parent': template_values.get('parent'), + 'sequence': template_values.get('sequence', 1), + 'country': template_values.get('country', ''), + 'visible': template_values.get('visible', True), 'installed': module.state == "installed", 'module': module.name, } for _name, mdl in getmembers(python_module, template_module) for _name, cls in getmembers(mdl, template_class) for _name, fct in getmembers(cls, template_function) + if (template_values := fct(ChartTemplate)) } module.account_templates = {