From df5438eeced92d3271ac9ac3876d9910d3e634a8 Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Fri, 23 Jun 2023 08:57:01 +0000 Subject: [PATCH] [IMP] account: allow to set chart_template install priority When you install a localization with multiple `chart_template`, the first one in alphabetical order is installed by default. This is not always the more relevant configuration. This PR adds an optional `sequence` parameter to `chart_template` that will be used to decide which one will be used when installing localization for the first time. opw-3328807 X-original-commit: ee6408250b13c3ef8160f7f777d9bb8efcaeb37d Part-of: odoo/odoo#126649 --- addons/account/models/ir_module.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/ir_module.py b/addons/account/models/ir_module.py index 995a5c1eb5d..bbc0b58b021 100644 --- a/addons/account/models/ir_module.py +++ b/addons/account/models/ir_module.py @@ -44,6 +44,7 @@ class IrModule(models.Model): 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), 'installed': module.state == "installed", @@ -56,7 +57,7 @@ class IrModule(models.Model): module.account_templates = { code: templ(self.env, code, **vals) - for code, vals in templates.items() + for code, vals in sorted(templates.items(), key=lambda kv: kv[1]['sequence']) } def write(self, vals):