From 956d67fca8c5fca850544f19394e5b12ec44212f Mon Sep 17 00:00:00 2001 From: KKamaa Date: Thu, 9 Feb 2023 01:29:54 +0300 Subject: [PATCH] [UPD] isort,prettier,black --- support_branding/models/res_company.py | 20 ++++++++------ .../static/src/js/res_config_edition.js | 21 +++++++-------- .../static/src/js/support_branding.js | 21 +++++++-------- support_branding/static/src/js/user_menu.js | 9 ++++--- .../tests/test_support_branding.py | 27 +++++++++++-------- 5 files changed, 54 insertions(+), 44 deletions(-) diff --git a/support_branding/models/res_company.py b/support_branding/models/res_company.py index ab7ecee42..34d94bd5a 100644 --- a/support_branding/models/res_company.py +++ b/support_branding/models/res_company.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import _, api, models -from odoo.exceptions import UserError, AccessError +from odoo.exceptions import AccessError class ResCompany(models.Model): @@ -10,15 +10,19 @@ class ResCompany(models.Model): @api.model def get_support_branding_config_param_data(self): - if not self.env.user.has_group('base.group_user'): - raise AccessError(_('You are not allowed to access this ' - 'functionality, please contact Admin for ' - 'more support')) + if not self.env.user.has_group("base.group_user"): + raise AccessError( + _( + "You are not allowed to access this " + "functionality, please contact Admin for " + "more support" + ) + ) self.env.cr.execute( - "select key, value from ir_config_parameter where key ilike " - "'%support_%';" + "select key, value from ir_config_parameter where key ilike " + "'%support_%';" ) res = self.env.cr.dictfetchall() if any(res): - support_vals = {x['key']: x['value'] for x in res} + support_vals = {x["key"]: x["value"] for x in res} return support_vals diff --git a/support_branding/static/src/js/res_config_edition.js b/support_branding/static/src/js/res_config_edition.js index cabe19aa7..ce0fc970a 100644 --- a/support_branding/static/src/js/res_config_edition.js +++ b/support_branding/static/src/js/res_config_edition.js @@ -11,17 +11,16 @@ odoo.define("support_branding.ResConfigEdition", function (require) { method: "get_support_branding_config_param_data", args: [], }).then(function (result) { - if (result && 'support_company' in result) - self.support_cp_name = result['support_company']; - if (result && 'support_company_url' in result) - self.support_cp_url = result['support_company_url']; - if (result && 'support_email' in result) - self.support_cp_email = result['support_email']; - if (result && 'support_release' in result) - self.support_cp_release = result['support_release']; - if (result && 'support_branding_color' in result) - self.support_branding_color = result[ - 'support_branding_color']; + if (result && "support_company" in result) + self.support_cp_name = result.support_company; + if (result && "support_company_url" in result) + self.support_cp_url = result.support_company_url; + if (result && "support_email" in result) + self.support_cp_email = result.support_email; + if (result && "support_release" in result) + self.support_cp_release = result.support_release; + if (result && "support_branding_color" in result) + self.support_branding_color = result.support_branding_color; }); return $.when(this._super.apply(this, arguments), def_1); diff --git a/support_branding/static/src/js/support_branding.js b/support_branding/static/src/js/support_branding.js index 702c73820..4963a79e1 100644 --- a/support_branding/static/src/js/support_branding.js +++ b/support_branding/static/src/js/support_branding.js @@ -23,17 +23,16 @@ odoo.define("support_branding.CrashManager", function (require) { method: "get_support_branding_config_param_data", args: [], }).then(function (result) { - if (result && 'support_company' in result) - self.support_cp_name = result['support_company']; - if (result && 'support_company_url' in result) - self.support_cp_url = result['support_company_url']; - if (result && 'support_email' in result) - self.support_cp_email = result['support_email']; - if (result && 'support_release' in result) - self.support_cp_release = result['support_release']; - if (result && 'support_branding_color' in result) - self.support_branding_color = result[ - 'support_branding_color']; + if (result && "support_company" in result) + self.support_cp_name = result.support_company; + if (result && "support_company_url" in result) + self.support_cp_url = result.support_company_url; + if (result && "support_email" in result) + self.support_cp_email = result.support_email; + if (result && "support_release" in result) + self.support_cp_release = result.support_release; + if (result && "support_branding_color" in result) + self.support_branding_color = result.support_branding_color; }); }); }, diff --git a/support_branding/static/src/js/user_menu.js b/support_branding/static/src/js/user_menu.js index 118d3834c..2ee54a4f8 100644 --- a/support_branding/static/src/js/user_menu.js +++ b/support_branding/static/src/js/user_menu.js @@ -17,9 +17,12 @@ odoo.define("support_branding.UserMenu", function (require) { args: [], }) .then(function (result) { - if (result && 'support_company_url' in result && - result['support_company_url'] !== "") { - self.support_url = result['support_company_url']; + if ( + result && + "support_company_url" in result && + result.support_company_url !== "" + ) { + self.support_url = result.support_company_url; } }); return $.when(this._super.apply(this, arguments), def); diff --git a/support_branding/tests/test_support_branding.py b/support_branding/tests/test_support_branding.py index 1cbd0ea7c..44d33275f 100644 --- a/support_branding/tests/test_support_branding.py +++ b/support_branding/tests/test_support_branding.py @@ -1,7 +1,7 @@ # Copyright 2023 Sunflower IT # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.exceptions import AccessError, UserError +from odoo.exceptions import AccessError from odoo.tests.common import TransactionCase @@ -36,20 +36,25 @@ class TestSupportBranding(TransactionCase): ) vals = self.company_obj.with_user( - self.demo_user).get_support_branding_config_param_data() + self.demo_user + ).get_support_branding_config_param_data() - self.assertEquals(vals['support_company'], - self.demo_support_branding_company_name.value) + self.assertEquals( + vals["support_company"], self.demo_support_branding_company_name.value + ) # Check if admin user is able to access # admin has access all through vals_1 = self.company_obj.with_user( - self.admin_user).get_support_branding_config_param_data() + self.admin_user + ).get_support_branding_config_param_data() vals_2 = self.company_obj.with_user( - self.admin_user).get_support_branding_config_param_data() + self.admin_user + ).get_support_branding_config_param_data() self.assertEquals(vals_1, vals_2) - self.assertEquals(vals_1['support_company_url'], - self.demo_support_company_branding_url.value) - self.assertEquals(vals_2['support_company_url'], - self.demo_support_company_branding_url.value) - + self.assertEquals( + vals_1["support_company_url"], self.demo_support_company_branding_url.value + ) + self.assertEquals( + vals_2["support_company_url"], self.demo_support_company_branding_url.value + )