[UPD] isort,prettier,black

This commit is contained in:
KKamaa
2023-02-09 01:29:54 +03:00
parent ac624eb7fc
commit 956d67fca8
5 changed files with 54 additions and 44 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
});
});
},

View File

@@ -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);

View File

@@ -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
)