pre-commit, black, isort

pull/2311/head
OCA-git-bot 2019-10-12 12:32:55 +02:00 committed by Benoit Aimont
parent 29202aa06b
commit 3948b91fab
3 changed files with 28 additions and 38 deletions

View File

@ -5,21 +5,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Web Environment Ribbon",
'version': '13.0.1.0.0',
'category': 'Web',
'author': 'Francesco OpenCode Apruzzese, '
'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/web',
'license': 'AGPL-3',
"depends": [
'web',
],
"data": [
'data/ribbon_data.xml',
'view/base_view.xml',
],
"name": "Web Environment Ribbon",
"version": "13.0.1.0.0",
"category": "Web",
"author": "Francesco OpenCode Apruzzese, "
"Tecnativa, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3",
"depends": ["web"],
"data": ["data/ribbon_data.xml", "view/base_view.xml"],
"auto_install": False,
'installable': True
"installable": True,
}

View File

@ -6,19 +6,16 @@ from odoo import api, models
class WebEnvironmentRibbonBackend(models.AbstractModel):
_name = 'web.environment.ribbon.backend'
_description = 'Web Environment Ribbon Backend'
_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,
}
return {"db_name": self.env.cr.dbname}
@api.model
def _prepare_ribbon_name(self):
name_tmpl = self.env['ir.config_parameter'].sudo().get_param(
'ribbon.name')
name_tmpl = self.env["ir.config_parameter"].sudo().get_param("ribbon.name")
vals = self._prepare_ribbon_format_vals()
return name_tmpl and name_tmpl.format(**vals) or name_tmpl
@ -28,11 +25,12 @@ class WebEnvironmentRibbonBackend(models.AbstractModel):
This method returns the ribbon data from ir config parameters
:return: dictionary
"""
ir_config_model = self.env['ir.config_parameter']
ir_config_model = self.env["ir.config_parameter"]
name = self._prepare_ribbon_name()
return {
'name': name,
'color': ir_config_model.sudo().get_param('ribbon.color'),
'background_color': ir_config_model.sudo().get_param(
'ribbon.background.color'),
"name": name,
"color": ir_config_model.sudo().get_param("ribbon.color"),
"background_color": ir_config_model.sudo().get_param(
"ribbon.background.color"
),
}

View File

@ -8,22 +8,19 @@ class TestEnvironmentRibbonData(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestEnvironmentRibbonData, cls).setUpClass()
cls.env['ir.config_parameter'].set_param(
'ribbon.name', 'Test Ribbon {db_name}')
cls.env['ir.config_parameter'].set_param('ribbon.color', '#000000')
cls.env['ir.config_parameter'].set_param(
'ribbon.background.color', '#FFFFFF')
cls.env["ir.config_parameter"].set_param("ribbon.name", "Test Ribbon {db_name}")
cls.env["ir.config_parameter"].set_param("ribbon.color", "#000000")
cls.env["ir.config_parameter"].set_param("ribbon.background.color", "#FFFFFF")
def test_environment_ribbon(self):
"""This test confirms that the data that is fetched by the javascript
code is the right title and colors."""
ribbon = self.env['web.environment.ribbon.backend'].\
get_environment_ribbon()
ribbon = self.env["web.environment.ribbon.backend"].get_environment_ribbon()
expected_ribbon = {
'name': 'Test Ribbon {db_name}'.format(db_name=self.env.cr.dbname),
'color': '#000000',
'background_color': '#FFFFFF'
"name": "Test Ribbon {db_name}".format(db_name=self.env.cr.dbname),
"color": "#000000",
"background_color": "#FFFFFF",
}
self.assertDictEqual(ribbon, expected_ribbon)