mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[UPD] isort,prettier,black
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user