Skip to content

Commit

Permalink
[MIG] server_environment: migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr authored and simahawk committed Oct 22, 2021
1 parent 03012cf commit dfad546
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server_environment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "server configuration environment files",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"depends": ["base", "base_sparse_field"],
"author": "Camptocamp,Odoo Community Association (OCA)",
"summary": "move some configurations out of the database",
Expand Down
1 change: 1 addition & 0 deletions server_environment/models/server_env_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,4 @@ def _setup_base(self):
self._server_env_add_default_field(field)
self._server_env_transform_field_to_read_from_env(field)
self._server_env_add_is_editable_field(field)
return
14 changes: 9 additions & 5 deletions server_environment/server_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def _load_config_from_server_env_files(config_p):
try:
config_p.read(conf_files)
except Exception as e:
raise Exception('Cannot read config files "{}": {}'.format(conf_files, e))
raise Exception(
'Cannot read config files "{}": {}'.format(conf_files, e)
) from e


def _load_config_from_rcfile(config_p):
Expand All @@ -128,7 +130,7 @@ def _load_config_from_env(config_p):
except configparser.Error as err:
raise Exception(
"{} content could not be parsed: {}".format(varname, err)
)
) from err


def _load_config():
Expand Down Expand Up @@ -213,7 +215,7 @@ def _add_columns(cls):

@classmethod
def _get_base_cols(cls):
""" Compute base fields"""
"""Compute base fields"""
res = {}
for col, item in list(system_base_config.options.items()):
key = cls._format_key("odoo", col)
Expand All @@ -222,7 +224,7 @@ def _get_base_cols(cls):

@classmethod
def _get_env_cols(cls, sections=None):
""" Compute base fields"""
"""Compute base fields"""
res = {}
sections = sections if sections else serv_config.sections()
for section in sections:
Expand All @@ -233,7 +235,7 @@ def _get_env_cols(cls, sections=None):

@classmethod
def _get_system_cols(cls):
""" Compute system fields"""
"""Compute system fields"""
res = {}
for col, item in get_server_environment():
key = cls._format_key("system", col)
Expand Down Expand Up @@ -316,6 +318,8 @@ def default_get(self, fields_list):
):
return res
for key in self._conf_defaults:
if key not in fields_list:
continue
if not self.show_passwords and self._is_secret(key=key):
res[key] = "**********"
else:
Expand Down
2 changes: 1 addition & 1 deletion server_environment/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from odoo.addons.server_environment import server_env


class ServerEnvironmentCase(common.SavepointCase):
class ServerEnvironmentCase(common.TransactionCase):
@contextmanager
def set_config_dir(self, path):
original_dir = server_env._dir
Expand Down
4 changes: 3 additions & 1 deletion server_environment/tests/test_server_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def test_view(self):
def _test_default(self, hidden_pwd=False):
model = self.env["server.config"]
rec = model.create({})
defaults = rec.default_get([])
fields = model.fields_view_get()["fields"]
self.assertTrue(fields)
defaults = rec.default_get(list(fields))
self.assertTrue(defaults)
self.assertIsInstance(defaults, dict)
pass_checked = False
Expand Down
1 change: 1 addition & 0 deletions setup/server_environment/odoo/addons/server_environment
6 changes: 6 additions & 0 deletions setup/server_environment/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit dfad546

Please sign in to comment.