mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[UPD] black,isort,prettier
This commit is contained in:
@@ -3,4 +3,3 @@
|
||||
|
||||
from . import res_config_settings
|
||||
from . import res_company
|
||||
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -2,7 +2,3 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_support_branding
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user