[IMP] l10n_es: default chart template
When you create a new Spanish DB, by default the installed localization package is the one for non-profit localization. This is probably the most convenient, as the most normal usage for standard Odoo is the PYMEs one. This PR modify the demo data and also change the order of how they are displayed in the fiscal position setting. In the ir_module, the added line will get the order of module of the init file, and will sort the template with that order so that we can prioritize some template. closes odoo/odoo#122254 Task-id: 3336598 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<function model="account.chart.template" name="try_loading">
|
||||
<value eval="[]"/>
|
||||
<value>es_assec</value>
|
||||
<value>es_pymes</value>
|
||||
<value model="res.company" eval="obj().env.ref('l10n_es.demo_company_es')"/>
|
||||
</function>
|
||||
</odoo>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user