[MIG] server_environment: Migration to 16.0
This commit is contained in:
parent
961cf7e1f8
commit
b63ea4b3c0
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "server configuration environment files",
|
"name": "server configuration environment files",
|
||||||
"version": "16.0.1.1.1",
|
"version": "16.0.1.0.0",
|
||||||
"depends": ["base", "base_sparse_field"],
|
"depends": ["base", "base_sparse_field"],
|
||||||
"author": "Camptocamp,Odoo Community Association (OCA)",
|
"author": "Camptocamp,Odoo Community Association (OCA)",
|
||||||
"summary": "move some configurations out of the database",
|
"summary": "move some configurations out of the database",
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,11 @@ class ServerEnvTechNameMixin(models.AbstractModel):
|
||||||
# make sure is normalized
|
# make sure is normalized
|
||||||
self.tech_name = self._normalize_tech_name(self.tech_name)
|
self.tech_name = self._normalize_tech_name(self.tech_name)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
self._handle_tech_name(vals)
|
for vals in vals_list:
|
||||||
return super().create(vals)
|
self._handle_tech_name(vals)
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
self._handle_tech_name(vals)
|
self._handle_tech_name(vals)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
<odoo>
|
<odoo>
|
||||||
<record model="res.groups" id="has_server_configuration_access">
|
<record model="res.groups" id="has_server_configuration_access">
|
||||||
<field name="name">View Server Environment Configuration</field>
|
<field name="name">View Server Environment Configuration</field>
|
||||||
<field name="users" eval="[(4, ref('base.user_root'))]" />
|
<field
|
||||||
|
name="users"
|
||||||
|
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ try:
|
||||||
_dir = os.path.dirname(server_environment_files.__file__)
|
_dir = os.path.dirname(server_environment_files.__file__)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"not using server_environment_files for configuration," " no directory found"
|
"not using server_environment_files for configuration, no directory found"
|
||||||
)
|
)
|
||||||
_dir = None
|
_dir = None
|
||||||
|
|
||||||
|
|
@ -202,15 +202,18 @@ class ServerConfiguration(models.TransientModel):
|
||||||
)
|
)
|
||||||
for col, value in cols:
|
for col, value in cols:
|
||||||
col_name = col.replace(".", "_")
|
col_name = col.replace(".", "_")
|
||||||
|
tmp_field = fields.Char(
|
||||||
|
string=cls._format_key_display_name(col_name),
|
||||||
|
sparse="config",
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
setattr(
|
setattr(
|
||||||
ServerConfiguration,
|
ServerConfiguration,
|
||||||
col_name,
|
col_name,
|
||||||
fields.Char(
|
tmp_field,
|
||||||
string=cls._format_key_display_name(col_name),
|
|
||||||
sparse="config",
|
|
||||||
readonly=True,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
tmp_field.name = col_name
|
||||||
|
ServerConfiguration._field_definitions.append(tmp_field)
|
||||||
cls._conf_defaults[col_name] = value
|
cls._conf_defaults[col_name] = value
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -287,17 +290,14 @@ class ServerConfiguration(models.TransientModel):
|
||||||
cls._arch = etree.fromstring(arch)
|
cls._arch = etree.fromstring(arch)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def fields_view_get(
|
def get_view(self, view_id=None, view_type="form", **options):
|
||||||
self, view_id=None, view_type="form", toolbar=False, submenu=False
|
res = super().get_view(view_id, view_type, **options)
|
||||||
):
|
|
||||||
"""Overwrite the default method to render the custom view."""
|
|
||||||
res = super().fields_view_get(view_id, view_type, toolbar)
|
|
||||||
View = self.env["ir.ui.view"].browse(view_id)
|
View = self.env["ir.ui.view"].browse(view_id)
|
||||||
if view_type == "form":
|
if view_type == "form":
|
||||||
arch_node = self._arch
|
arch, models = View.postprocess_and_fields(
|
||||||
xarch, xfields = View.postprocess_and_fields(arch_node, model=self._name)
|
self._arch, model=self._name, **options
|
||||||
res["arch"] = xarch
|
)
|
||||||
res["fields"] = xfields
|
res["arch"] = arch
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ from . import common
|
||||||
class TestEnv(common.ServerEnvironmentCase):
|
class TestEnv(common.ServerEnvironmentCase):
|
||||||
def test_view(self):
|
def test_view(self):
|
||||||
model = self.env["server.config"]
|
model = self.env["server.config"]
|
||||||
view = model.fields_view_get()
|
view = model.get_view()
|
||||||
self.assertTrue(view)
|
self.assertTrue(view)
|
||||||
|
|
||||||
def _test_default(self, hidden_pwd=False):
|
def _test_default(self, hidden_pwd=False):
|
||||||
model = self.env["server.config"]
|
model = self.env["server.config"]
|
||||||
rec = model.create({})
|
rec = model.create({})
|
||||||
fields = model.fields_view_get()["fields"]
|
fields = model.fields_get()
|
||||||
self.assertTrue(fields)
|
self.assertTrue(fields)
|
||||||
defaults = rec.default_get(list(fields))
|
defaults = rec.default_get(list(fields))
|
||||||
self.assertTrue(defaults)
|
self.assertTrue(defaults)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../server_environment
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue