diff --git a/support_branding/models/res_company.py b/support_branding/models/res_company.py index 6fac976df..d7d2dccc2 100644 --- a/support_branding/models/res_company.py +++ b/support_branding/models/res_company.py @@ -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 diff --git a/support_branding/tests/test_support_branding.py b/support_branding/tests/test_support_branding.py index 048f76f85..2eccc5847 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 +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)