diff --git a/addons/account/models/ir_module.py b/addons/account/models/ir_module.py index 430c1737a12..b7552605161 100644 --- a/addons/account/models/ir_module.py +++ b/addons/account/models/ir_module.py @@ -1,5 +1,5 @@ from importlib import import_module -from inspect import getmembers, ismodule, isclass, isfunction +from inspect import getmembers, ismodule, isclass, isfunction, getsourcelines from odoo import models, fields from odoo.tools import get_flag @@ -36,6 +36,9 @@ class IrModule(models.Model): except ModuleNotFoundError: templates = {} else: + #This will allow to get the order of the init file, This will be useful for locations with several + #templates, one or more of which you want to prioritize. + module_order = {w: i for i, w in enumerate(''.join(getsourcelines(python_module)[0]).split())} templates = { fct._l10n_template[0]: { 'name': fct(ChartTemplate).get('name'), @@ -44,7 +47,7 @@ class IrModule(models.Model): 'visible': fct(ChartTemplate).get('visible', True), 'module': module.name, } - for _name, mdl in getmembers(python_module, template_module) + for _name, mdl in sorted(getmembers(python_module, template_module), key=(lambda mdl: module_order[mdl[0]])) for _name, cls in getmembers(mdl, template_class) for _name, fct in getmembers(cls, template_function) } diff --git a/addons/l10n_es/demo/demo_company.xml b/addons/l10n_es/demo/demo_company.xml index fdb8cd2ad21..833e9cb72ad 100644 --- a/addons/l10n_es/demo/demo_company.xml +++ b/addons/l10n_es/demo/demo_company.xml @@ -29,7 +29,7 @@ - es_assec + es_pymes diff --git a/addons/l10n_es/models/__init__.py b/addons/l10n_es/models/__init__.py index 1074e642805..3a3ab2e6bd6 100644 --- a/addons/l10n_es/models/__init__.py +++ b/addons/l10n_es/models/__init__.py @@ -1,5 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import template_es_pymes from . import template_es_full from . import template_es_assec -from . import template_es_pymes from . import template_es_common