fixup! Add module server_environment_data_encryption

This commit is contained in:
Florian da Costa 2019-10-23 16:33:55 +02:00 committed by Sébastien BEAU
parent e0949fb9d2
commit e55d5a314e
3 changed files with 9 additions and 13 deletions

View File

@ -4,11 +4,9 @@
"version": "12.0.1.0.0", "version": "12.0.1.0.0",
"development_status": 'Alpha', "development_status": 'Alpha',
"category": "Tools", "category": "Tools",
"website": "https://akretion.com/", "website": "https://github.com/OCA/server-env",
"author": "Akretion, Odoo Community Association (OCA)", "author": "Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"application": False,
"installable": True, "installable": True,
"depends": ["server_environment", "data_encryption"], "depends": ["server_environment", "data_encryption"],
"data": [],
} }

View File

@ -15,7 +15,7 @@ class ServerEnvMixin(models.AbstractModel):
_inherit = "server.env.mixin" _inherit = "server.env.mixin"
def _compute_server_env_from_default(self, field_name, options): def _compute_server_env_from_default(self, field_name, options):
"First return database encrypted value then default value" """ First return database encrypted value then default value """
self.ensure_one() self.ensure_one()
encrypted_data_name = "%s,%s" % (self._name, self.id) encrypted_data_name = "%s,%s" % (self._name, self.id)
env = self.env.context.get("environment", None) env = self.env.context.get("environment", None)
@ -54,11 +54,12 @@ class ServerEnvMixin(models.AbstractModel):
def action_change_env_data_encrypted_fields(self): def action_change_env_data_encrypted_fields(self):
action_id = self.env.context.get("params", {}).get("action") action_id = self.env.context.get("params", {}).get("action")
if not action_id: if not action_id:
# We don't know which action we are using... take one random. # We don't know which action we are using... take default one
action_id = self.env['ir.actions.act_window'].search( action = self.get_formview_action()
[('res_model', '=', self._name)], limit=1).id else:
action = self.env["ir.actions.act_window"].browse(action_id).read()[0] action = self.env["ir.actions.act_window"].browse(
action["view_mode"] = "form" action_id).read()[0]
action["view_mode"] = "form"
action["res_id"] = self.id action["res_id"] = self.id
views_form = [] views_form = []
for view_id, view_type in action.get("views", []): for view_id, view_type in action.get("views", []):
@ -68,6 +69,7 @@ class ServerEnvMixin(models.AbstractModel):
return action return action
def _get_extra_environment_info_div(self, current_env, extra_envs): def _get_extra_environment_info_div(self, current_env, extra_envs):
# TODO we could use a qweb template here
button_div = "<div>" button_div = "<div>"
button_string = _("Define values for ") button_string = _("Define values for ")
for environment in extra_envs: for environment in extra_envs:

View File

@ -6,10 +6,6 @@ from pathlib import Path
class TestServerEnvDataEncrypted(CommonDataEncrypted): class TestServerEnvDataEncrypted(CommonDataEncrypted):
# def test_store_data_no_superuser(self):
# self.env['server.env.mixin']._inverse_server_env('test')
# pass
def test_dynamic_view_current_env(self): def test_dynamic_view_current_env(self):
self.maxDiff = None self.maxDiff = None
self.set_new_key_env("prod") self.set_new_key_env("prod")