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.
This commit is contained in:
parent
c6929e20ae
commit
b8e86de50c
|
|
@ -28,6 +28,8 @@ from lxml import etree
|
||||||
from odoo import api, fields, models
|
from odoo import api, fields, models
|
||||||
from odoo.tools.config import config as system_base_config
|
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
|
from .system_info import get_server_environment
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
@ -172,6 +174,8 @@ class ServerConfiguration(models.TransientModel):
|
||||||
_description = "Display server configuration"
|
_description = "Display server configuration"
|
||||||
_conf_defaults = _Defaults()
|
_conf_defaults = _Defaults()
|
||||||
|
|
||||||
|
config = Serialized()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _build_model(cls, pool, cr):
|
def _build_model(cls, pool, cr):
|
||||||
"""Add columns to model dynamically
|
"""Add columns to model dynamically
|
||||||
|
|
@ -209,7 +213,9 @@ class ServerConfiguration(models.TransientModel):
|
||||||
ServerConfiguration,
|
ServerConfiguration,
|
||||||
col_name,
|
col_name,
|
||||||
fields.Char(
|
fields.Char(
|
||||||
string=cls._format_key_display_name(col_name), readonly=True
|
string=cls._format_key_display_name(col_name),
|
||||||
|
sparse="config",
|
||||||
|
readonly=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
cls._conf_defaults[col_name] = value
|
cls._conf_defaults[col_name] = value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue