From e6018eb49ea0014eb8c9270c9a33411dc32fd7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Sun, 2 Jul 2017 22:18:47 +0200 Subject: [PATCH] [IMP] ribbon: better extensibility --- .../models/web_environment_ribbon_backend.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web_environment_ribbon/models/web_environment_ribbon_backend.py b/web_environment_ribbon/models/web_environment_ribbon_backend.py index bb7b0f5a..b6ba8c16 100644 --- a/web_environment_ribbon/models/web_environment_ribbon_backend.py +++ b/web_environment_ribbon/models/web_environment_ribbon_backend.py @@ -10,12 +10,17 @@ class WebEnvironmentRibbonBackend(models.AbstractModel): _name = 'web.environment.ribbon.backend' _description = 'Web Environment Ribbon Backend' + @api.model + def _prepare_ribbon_format_vals(self): + return { + 'db_name': self.env.cr.dbname, + } + @api.model def _prepare_ribbon_name(self): - db_name = self.env.cr.dbname - name = self.env['ir.config_parameter'].get_param('ribbon.name') - name = name.format(db_name=db_name) - return name + name_tmpl = self.env['ir.config_parameter'].get_param('ribbon.name') + vals = self._prepare_ribbon_format_vals() + return name_tmpl.format(**vals) @api.model def get_environment_ribbon(self):