From 47f23fb308078f3127d91223a8b1ee279a46632f Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 3 Dec 2019 17:26:50 +0100 Subject: [PATCH] Store the 'server.config' fields in sparse fields This model is used only to display the configuration to authorized users. It's a TransientModel that dynamically creates the fields for every odoo configuration parameter, environment variables and some system ones. Before this change, each new parameter/variable will create a field in database, which can lead to many issues (lot of fields, field name too long). Storing the fields in a single JSON field resolves these issues and is much cleaner anyway. --- server_environment/serv_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server_environment/serv_config.py b/server_environment/serv_config.py index a18bd22..6662765 100644 --- a/server_environment/serv_config.py +++ b/server_environment/serv_config.py @@ -26,6 +26,7 @@ from itertools import chain from odoo import api, models, fields from odoo.tools.config import config as system_base_config +from odoo.addons.base_sparse_field.models.fields import Serialized from .system_info import get_server_environment @@ -156,6 +157,8 @@ class ServerConfiguration(models.TransientModel): _description = 'Display server configuration' _conf_defaults = _Defaults() + config = Serialized() + @classmethod def _build_model(cls, pool, cr): """Add columns to model dynamically @@ -193,6 +196,7 @@ class ServerConfiguration(models.TransientModel): col_name, fields.Char( string=cls._format_key_display_name(col_name), + sparse='config', readonly=True) ) cls._conf_defaults[col_name] = value