3
0
Fork 0

[FIX] check for invalid key

14.0
KKamaa 2023-01-31 05:55:00 +03:00
parent 44c66fecb5
commit fcaf19d858
2 changed files with 16 additions and 8 deletions

View File

@ -1,11 +1,8 @@
# Copyright 2023 Sunflower IT
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
from odoo import api, models
_logger = logging.getLogger(__name__)
from odoo import _, api, models
from odoo.exceptions import UserError
class ResCompany(models.Model):
@ -19,8 +16,7 @@ class ResCompany(models.Model):
)
res = self.env.cr.fetchone()
except Exception as e:
_logger.error("\n\n ERROR: %s \n\n", e)
return ""
raise UserError(_("Error: %s" % e))
else:
if res:
return "%s" % res

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
from odoo.exceptions import AccessError, UserError
from odoo.tests.common import TransactionCase
@ -45,3 +45,15 @@ class TestSupportBranding(TransactionCase):
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)
# check if return if key is invalid
empty_val = self.company_obj.with_user(
self.admin_user
).get_ir_config_param_data("testing")
self.assertEquals(empty_val, "")
# check if return of key if invalid
with self.assertRaises(UserError):
empty_val = self.company_obj.with_user(
self.admin_user
).get_ir_config_param_data(True)