From 44c66fecb54aaca63467830e0973412bdd8ac391 Mon Sep 17 00:00:00 2001 From: KKamaa Date: Tue, 31 Jan 2023 05:22:24 +0300 Subject: [PATCH] [UPD] black,isort,prettier --- support_branding/models/__init__.py | 1 - support_branding/models/res_company.py | 20 +++++----- support_branding/tests/__init__.py | 4 -- .../tests/test_support_branding.py | 39 ++++++++++--------- 4 files changed, 29 insertions(+), 35 deletions(-) diff --git a/support_branding/models/__init__.py b/support_branding/models/__init__.py index 97359ec5c..c873322e0 100644 --- a/support_branding/models/__init__.py +++ b/support_branding/models/__init__.py @@ -3,4 +3,3 @@ from . import res_config_settings from . import res_company - diff --git a/support_branding/models/res_company.py b/support_branding/models/res_company.py index bc315e381..6fac976df 100644 --- a/support_branding/models/res_company.py +++ b/support_branding/models/res_company.py @@ -3,27 +3,25 @@ import logging -from odoo import models, api +from odoo import api, models _logger = logging.getLogger(__name__) class ResCompany(models.Model): - _inherit = 'res.company' + _inherit = "res.company" @api.model def get_ir_config_param_data(self, key): try: - self.env.cr.execute("select value from ir_config_parameter where " - "key='%s';" % key) + self.env.cr.execute( + "select value from ir_config_parameter where " "key=(%s);", (key,) + ) res = self.env.cr.fetchone() except Exception as e: - _logger.error('\n\n ERROR: %s \n\n', e) - return '' + _logger.error("\n\n ERROR: %s \n\n", e) + return "" else: if res: - return '%s' % res - return '' - - - + return "%s" % res + return "" diff --git a/support_branding/tests/__init__.py b/support_branding/tests/__init__.py index 115114ba9..1a36f0c42 100644 --- a/support_branding/tests/__init__.py +++ b/support_branding/tests/__init__.py @@ -2,7 +2,3 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import test_support_branding - - - - diff --git a/support_branding/tests/test_support_branding.py b/support_branding/tests/test_support_branding.py index 506bc206c..048f76f85 100644 --- a/support_branding/tests/test_support_branding.py +++ b/support_branding/tests/test_support_branding.py @@ -1,21 +1,23 @@ # Copyright 2023 Sunflower IT # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests.common import TransactionCase from odoo.exceptions import AccessError +from odoo.tests.common import TransactionCase class TestSupportBranding(TransactionCase): def setUp(self): super(TestSupportBranding, self).setUp() - self.company_obj = self.env['res.company'] - self.ir_config_obj = self.env['ir.config_parameter'].sudo() - self.demo_user = self.env.ref('base.user_demo') - self.admin_user = self.env.ref('base.user_admin') + self.company_obj = self.env["res.company"] + self.ir_config_obj = self.env["ir.config_parameter"].sudo() + self.demo_user = self.env.ref("base.user_demo") + self.admin_user = self.env.ref("base.user_admin") self.demo_support_branding_company_name = self.env.ref( - 'support_branding.demo_config_parameter_company_name') + "support_branding.demo_config_parameter_company_name" + ) self.demo_support_company_branding_url = self.env.ref( - 'support_branding.demo_config_parameter_company_url') + "support_branding.demo_config_parameter_company_url" + ) def test_fetch_support_branding_vals_from_res_company(self): @@ -23,24 +25,23 @@ class TestSupportBranding(TransactionCase): # NB: ir.config_parameter model requires admin access rights. with self.assertRaises(AccessError): self.ir_config_obj.with_user(self.demo_user).get_param( - self.demo_support_company_branding_url.key) + self.demo_support_company_branding_url.key + ) - value = self.company_obj.with_user(self.demo_user) \ - .get_ir_config_param_data( - self.demo_support_company_branding_url.key) + value = self.company_obj.with_user(self.demo_user).get_ir_config_param_data( + self.demo_support_company_branding_url.key + ) self.assertEquals(value, self.demo_support_company_branding_url.value) # Check if admin user is able to access # admin has access all through - value_1 = self.company_obj.with_user(self.admin_user) \ - .get_ir_config_param_data( - self.demo_support_company_branding_url.key) - value_2 = self.company_obj.with_user(self.admin_user) \ - .get_ir_config_param_data( - self.demo_support_company_branding_url.key) + value_1 = self.company_obj.with_user(self.admin_user).get_ir_config_param_data( + self.demo_support_company_branding_url.key + ) + value_2 = self.company_obj.with_user(self.admin_user).get_ir_config_param_data( + self.demo_support_company_branding_url.key + ) self.assertEquals(value_1, value_2) self.assertEquals(value_1, self.demo_support_company_branding_url.value) self.assertEquals(value_2, self.demo_support_company_branding_url.value) - -