[FIX] use key/value pair for support branding

This commit is contained in:
KKamaa
2023-02-09 01:26:44 +03:00
parent 7553f530aa
commit ac624eb7fc
5 changed files with 65 additions and 107 deletions

View File

@@ -2,30 +2,23 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, models
from odoo.exceptions import AccessError, UserError
from odoo.exceptions import UserError, AccessError
class ResCompany(models.Model):
_inherit = "res.company"
@api.model
def get_ir_config_param_data(self, key):
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"
)
)
try:
self.env.cr.execute(
"select value from ir_config_parameter where " "key=(%s);", (key,)
)
res = self.env.cr.fetchone()
except Exception as e:
raise UserError(_("Error: %s" % e))
else:
if res:
return "%s" % res
return ""
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'))
self.env.cr.execute(
"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}
return support_vals