+ """.format(
+ alert_type, alert_string, button_div
+ )
+ )
+ return elem
+
+ def _set_readonly_form_view(self, doc):
+ for field in doc.iter("field"):
+ env_fields = self._server_env_fields.keys()
+ field_name = field.get("name")
+ if field_name in env_fields:
+ continue
+ field.set("readonly", "1")
+ setup_modifiers(field, self.fields_get(field_name))
+
+ def _update_form_view_from_env(self, arch, view_type):
+ if view_type != "form":
+ return arch
+ current_env = self.env.context.get("environment") or config.get(
+ "running_env"
+ )
+ other_environments = [
+ key[15:]
+ for key, val in config.options.items()
+ if key.startswith("encryption_key_")
+ and val
+ and key[15:] != current_env
+ ]
+
+ if not current_env:
+ raise ValidationError(
+ _(
+ "you need to define the running_env entry in your odoo "
+ "configuration file"
+ )
+ )
+ doc = etree.XML(arch)
+ node = doc.xpath("//sheet")
+ if node:
+ node = node[0]
+ elem = self._get_extra_environment_info_div(
+ current_env, other_environments
+ )
+ node.insert(0, elem)
+
+ if current_env != config.get("running_env"):
+ self._set_readonly_form_view(doc)
+ arch = etree.tostring(doc, pretty_print=True, encoding="unicode")
+ else:
+ _logger.error(
+ "Missing sheet for form view on object {}".format(self._name)
+ )
+ return arch
+
+ @api.model
+ def fields_view_get(
+ self, view_id=None, view_type="form", toolbar=False, submenu=False
+ ):
+ res = super().fields_view_get(
+ view_id=view_id,
+ view_type=view_type,
+ toolbar=toolbar,
+ submenu=submenu,
+ )
+ res["arch"] = self._update_form_view_from_env(res["arch"], view_type)
+ return res
diff --git a/server_environment_data_encryption/readme/CONFIGURE.rst b/server_environment_data_encryption/readme/CONFIGURE.rst
new file mode 100644
index 000000000..9d0ad4645
--- /dev/null
+++ b/server_environment_data_encryption/readme/CONFIGURE.rst
@@ -0,0 +1,24 @@
+In order to use this module properly, each environment should have their own encryption key
+and the production environment should have the keys of all environments.
+
+Example :
+Development environment ::
+
+ [options]
+ running_env=dev
+ encryption_key_dev=XXX
+
+Pre-production environment ::
+
+ [options]
+ running_env=preprod
+ encryption_key_preprod=YYY
+
+Production environment ::
+
+ [options]
+ running_env=prod
+ encryption_key_dev=XXX
+ encryption_key_preprod=YYY
+ encryption_key_prod=ZZZ
+
diff --git a/server_environment_data_encryption/readme/CONTRIBUTORS.rst b/server_environment_data_encryption/readme/CONTRIBUTORS.rst
new file mode 100644
index 000000000..86340ecd1
--- /dev/null
+++ b/server_environment_data_encryption/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* Florian da Costa
+* Sébastien Beau
+* Benoît Guillot
diff --git a/server_environment_data_encryption/readme/DESCRIPTION.rst b/server_environment_data_encryption/readme/DESCRIPTION.rst
new file mode 100644
index 000000000..ebf414798
--- /dev/null
+++ b/server_environment_data_encryption/readme/DESCRIPTION.rst
@@ -0,0 +1,6 @@
+This module changes a little the behavior of server_environment modules.
+When Odoo does not find the value of the field in the configuration file,
+it will fallback on a Odoo encrypted field instead.
+Also it allows you
+to configure the environment dependent fields for all your environments
+from the production server.
diff --git a/server_environment_data_encryption/tests/__init__.py b/server_environment_data_encryption/tests/__init__.py
new file mode 100644
index 000000000..83ac8b859
--- /dev/null
+++ b/server_environment_data_encryption/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_server_environment_data_encrypt
diff --git a/server_environment_data_encryption/tests/fixtures/base.xml b/server_environment_data_encryption/tests/fixtures/base.xml
new file mode 100644
index 000000000..524c95993
--- /dev/null
+++ b/server_environment_data_encryption/tests/fixtures/base.xml
@@ -0,0 +1,15 @@
+
diff --git a/server_environment_data_encryption/tests/fixtures/res1.xml b/server_environment_data_encryption/tests/fixtures/res1.xml
new file mode 100644
index 000000000..7ca515a86
--- /dev/null
+++ b/server_environment_data_encryption/tests/fixtures/res1.xml
@@ -0,0 +1,21 @@
+
diff --git a/server_environment_data_encryption/tests/fixtures/res2.xml b/server_environment_data_encryption/tests/fixtures/res2.xml
new file mode 100644
index 000000000..032e10881
--- /dev/null
+++ b/server_environment_data_encryption/tests/fixtures/res2.xml
@@ -0,0 +1,21 @@
+
diff --git a/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
new file mode 100644
index 000000000..44be5739b
--- /dev/null
+++ b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
@@ -0,0 +1,36 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo.addons.data_encryption.tests.common import CommonDataEncrypted
+from pathlib import Path
+
+
+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):
+ self.maxDiff = None
+ self.set_new_key_env("prod")
+ self.set_new_key_env("preprod")
+ mixin_obj = self.env["server.env.mixin"]
+ base_path = Path(__file__).parent / "fixtures" / "base.xml"
+ xml = base_path.read_text()
+ res_xml = mixin_obj._update_form_view_from_env(xml, "form")
+ expected_xml_path = Path(__file__).parent / "fixtures" / "res1.xml"
+ expected_xml = expected_xml_path.read_text()
+ self.assertEqual(res_xml, expected_xml)
+
+ def test_dynamic_view_other_env(self):
+ self.set_new_key_env("prod")
+ self.set_new_key_env("preprod")
+ mixin_obj = self.env["server.env.mixin"]
+ base_path = Path(__file__).parent / "fixtures" / "base.xml"
+ xml = base_path.read_text()
+ res_xml = mixin_obj.with_context(
+ environment="prod"
+ )._update_form_view_from_env(xml, "form")
+ expected_xml_path = Path(__file__).parent / "fixtures" / "res2.xml"
+ expected_xml = expected_xml_path.read_text()
+ self.assertEqual(res_xml, expected_xml)
From 201f63944ebb0d098b68e07875cf655b4a00e33d Mon Sep 17 00:00:00 2001
From: Florian da Costa
Date: Fri, 4 Oct 2019 19:57:19 +0200
Subject: [PATCH 02/23] [REF] Adapt method name after change is depency
---
server_environment_data_encryption/__manifest__.py | 3 ++-
.../models/server_env_mixin.py | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/server_environment_data_encryption/__manifest__.py b/server_environment_data_encryption/__manifest__.py
index c1452cc90..3d4d24839 100644
--- a/server_environment_data_encryption/__manifest__.py
+++ b/server_environment_data_encryption/__manifest__.py
@@ -1,7 +1,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Server Environment Data Encryption",
- "version": "12.0.0.0.1",
+ "version": "12.0.1.0.0",
+ "development_status": 'Alpha',
"category": "Tools",
"website": "https://akretion.com/",
"author": "Akretion, Odoo Community Association (OCA)",
diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py
index 5579c4a7a..8f4379994 100644
--- a/server_environment_data_encryption/models/server_env_mixin.py
+++ b/server_environment_data_encryption/models/server_env_mixin.py
@@ -22,7 +22,7 @@ def _compute_server_env_from_default(self, field_name, options):
vals = (
self.env["encrypted.data"]
.sudo()
- ._get_json(encrypted_data_name, env=env)
+ ._encrypted_read_json(encrypted_data_name, env=env)
)
if vals.get(field_name):
self[field_name] = vals[field_name]
@@ -42,12 +42,12 @@ def _inverse_server_env(self, field_name):
for record in self:
if record[is_editable_field]:
encrypted_data_name = "%s,%s" % (record._name, record.id)
- values = encrypted_data_obj._get_json(
+ values = encrypted_data_obj._encrypted_read_json(
encrypted_data_name, env=env
)
new_val = {field_name: record[field_name]}
values.update(new_val)
- encrypted_data_obj._store_json(
+ encrypted_data_obj._encrypted_store_json(
encrypted_data_name, values, env=env
)
From d51bebf41a7aad10f96fb5391f340a3bb7826eb2 Mon Sep 17 00:00:00 2001
From: Florian da Costa
Date: Fri, 4 Oct 2019 20:34:06 +0200
Subject: [PATCH 03/23] [FIX] Make sure the generated view is always the same
and the order of the button does not change randomly
---
.../models/server_env_mixin.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py
index 8f4379994..d6e16ede5 100644
--- a/server_environment_data_encryption/models/server_env_mixin.py
+++ b/server_environment_data_encryption/models/server_env_mixin.py
@@ -118,13 +118,17 @@ def _update_form_view_from_env(self, arch, view_type):
current_env = self.env.context.get("environment") or config.get(
"running_env"
)
- other_environments = [
+ # Important to keep this list sorted. It makes sure the button to
+ # switch environment will always be in the same order. (more user
+ # friendly) and the test would fail without it as the order could
+ # change randomly and the view would then also change randomly
+ other_environments = sorted([
key[15:]
for key, val in config.options.items()
if key.startswith("encryption_key_")
and val
and key[15:] != current_env
- ]
+ ])
if not current_env:
raise ValidationError(
From 24e7f6d232fd504ee70d1a7cc09aaf8f96ba298d Mon Sep 17 00:00:00 2001
From: Florian da Costa
Date: Wed, 23 Oct 2019 16:33:55 +0200
Subject: [PATCH 04/23] fixup! Add module server_environment_data_encryption
---
server_environment_data_encryption/__manifest__.py | 4 +---
.../models/server_env_mixin.py | 14 ++++++++------
.../tests/test_server_environment_data_encrypt.py | 4 ----
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/server_environment_data_encryption/__manifest__.py b/server_environment_data_encryption/__manifest__.py
index 3d4d24839..53ccd13fb 100644
--- a/server_environment_data_encryption/__manifest__.py
+++ b/server_environment_data_encryption/__manifest__.py
@@ -4,11 +4,9 @@
"version": "12.0.1.0.0",
"development_status": 'Alpha',
"category": "Tools",
- "website": "https://akretion.com/",
+ "website": "https://github.com/OCA/server-env",
"author": "Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
- "application": False,
"installable": True,
"depends": ["server_environment", "data_encryption"],
- "data": [],
}
diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py
index d6e16ede5..d969793fa 100644
--- a/server_environment_data_encryption/models/server_env_mixin.py
+++ b/server_environment_data_encryption/models/server_env_mixin.py
@@ -15,7 +15,7 @@ class ServerEnvMixin(models.AbstractModel):
_inherit = "server.env.mixin"
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()
encrypted_data_name = "%s,%s" % (self._name, self.id)
env = self.env.context.get("environment", None)
@@ -54,11 +54,12 @@ def _inverse_server_env(self, field_name):
def action_change_env_data_encrypted_fields(self):
action_id = self.env.context.get("params", {}).get("action")
if not action_id:
- # We don't know which action we are using... take one random.
- action_id = self.env['ir.actions.act_window'].search(
- [('res_model', '=', self._name)], limit=1).id
- action = self.env["ir.actions.act_window"].browse(action_id).read()[0]
- action["view_mode"] = "form"
+ # We don't know which action we are using... take default one
+ action = self.get_formview_action()
+ else:
+ action = self.env["ir.actions.act_window"].browse(
+ action_id).read()[0]
+ action["view_mode"] = "form"
action["res_id"] = self.id
views_form = []
for view_id, view_type in action.get("views", []):
@@ -68,6 +69,7 @@ def action_change_env_data_encrypted_fields(self):
return action
def _get_extra_environment_info_div(self, current_env, extra_envs):
+ # TODO we could use a qweb template here
button_div = "
"
button_string = _("Define values for ")
for environment in extra_envs:
diff --git a/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
index 44be5739b..4194626a3 100644
--- a/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
+++ b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
@@ -6,10 +6,6 @@
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):
self.maxDiff = None
self.set_new_key_env("prod")
From 1cfef5deb8b8ebc46fb3f6be5886d09b86dab4fb Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Sat, 28 Mar 2020 08:45:33 +0000
Subject: [PATCH 05/23] [UPD] Update server_environment_data_encryption.pot
---
.../server_environment_data_encryption.pot | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 server_environment_data_encryption/i18n/server_environment_data_encryption.pot
diff --git a/server_environment_data_encryption/i18n/server_environment_data_encryption.pot b/server_environment_data_encryption/i18n/server_environment_data_encryption.pot
new file mode 100644
index 000000000..0acf17bc5
--- /dev/null
+++ b/server_environment_data_encryption/i18n/server_environment_data_encryption.pot
@@ -0,0 +1,38 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * server_environment_data_encryption
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 12.0\n"
+"Report-Msgid-Bugs-To: \n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: server_environment_data_encryption
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:74
+#, python-format
+msgid "Define values for "
+msgstr ""
+
+#. module: server_environment_data_encryption
+#: model:ir.model,name:server_environment_data_encryption.model_server_env_mixin
+msgid "Mixin to add server environment in existing models"
+msgstr ""
+
+#. module: server_environment_data_encryption
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:86
+#, python-format
+msgid "Modify values for {} environment"
+msgstr ""
+
+#. module: server_environment_data_encryption
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:137
+#, python-format
+msgid "you need to define the running_env entry in your odoo configuration file"
+msgstr ""
+
From c1f5daa648e713620180e9f36a374491408fab63 Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Sat, 28 Mar 2020 08:50:05 +0000
Subject: [PATCH 06/23] [UPD] README.rst
---
server_environment_data_encryption/README.rst | 113 +++++
.../static/description/index.html | 459 ++++++++++++++++++
2 files changed, 572 insertions(+)
create mode 100644 server_environment_data_encryption/README.rst
create mode 100644 server_environment_data_encryption/static/description/index.html
diff --git a/server_environment_data_encryption/README.rst b/server_environment_data_encryption/README.rst
new file mode 100644
index 000000000..7b64980bc
--- /dev/null
+++ b/server_environment_data_encryption/README.rst
@@ -0,0 +1,113 @@
+==================================
+Server Environment Data Encryption
+==================================
+
+.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !! This file is generated by oca-gen-addon-readme !!
+ !! changes will be overwritten. !!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
+ :target: https://odoo-community.org/page/development-status
+ :alt: Alpha
+.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
+ :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
+ :alt: License: AGPL-3
+.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github
+ :target: https://github.com/OCA/server-env/tree/12.0/server_environment_data_encryption
+ :alt: OCA/server-env
+.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
+ :target: https://translation.odoo-community.org/projects/server-env-12-0/server-env-12-0-server_environment_data_encryption
+ :alt: Translate me on Weblate
+.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
+ :target: https://runbot.odoo-community.org/runbot/254/12.0
+ :alt: Try me on Runbot
+
+|badge1| |badge2| |badge3| |badge4| |badge5|
+
+This module changes a little the behavior of server_environment modules.
+When Odoo does not find the value of the field in the configuration file,
+it will fallback on a Odoo encrypted field instead.
+Also it allows you
+to configure the environment dependent fields for all your environments
+from the production server.
+
+.. IMPORTANT::
+ This is an alpha version, the data model and design can change at any time without warning.
+ Only for development or testing purpose, do not use in production.
+ `More details on development status `_
+
+**Table of contents**
+
+.. contents::
+ :local:
+
+Configuration
+=============
+
+In order to use this module properly, each environment should have their own encryption key
+and the production environment should have the keys of all environments.
+
+Example :
+Development environment ::
+
+ [options]
+ running_env=dev
+ encryption_key_dev=XXX
+
+Pre-production environment ::
+
+ [options]
+ running_env=preprod
+ encryption_key_preprod=YYY
+
+Production environment ::
+
+ [options]
+ running_env=prod
+ encryption_key_dev=XXX
+ encryption_key_preprod=YYY
+ encryption_key_prod=ZZZ
+
+
+Bug Tracker
+===========
+
+Bugs are tracked on `GitHub Issues `_.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+`feedback `_.
+
+Do not contact contributors directly about support or help with technical issues.
+
+Credits
+=======
+
+Authors
+~~~~~~~
+
+* Akretion
+
+Contributors
+~~~~~~~~~~~~
+
+* Florian da Costa
+* Sébastien Beau
+* Benoît Guillot
+
+Maintainers
+~~~~~~~~~~~
+
+This module is maintained by the OCA.
+
+.. image:: https://odoo-community.org/logo.png
+ :alt: Odoo Community Association
+ :target: https://odoo-community.org
+
+OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
+This module is part of the `OCA/server-env `_ project on GitHub.
+
+You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/server_environment_data_encryption/static/description/index.html b/server_environment_data_encryption/static/description/index.html
new file mode 100644
index 000000000..5bd6658eb
--- /dev/null
+++ b/server_environment_data_encryption/static/description/index.html
@@ -0,0 +1,459 @@
+
+
+
+
+
+
+Server Environment Data Encryption
+
+
+
+
+
Server Environment Data Encryption
+
+
+
+
This module changes a little the behavior of server_environment modules.
+When Odoo does not find the value of the field in the configuration file,
+it will fallback on a Odoo encrypted field instead.
+Also it allows you
+to configure the environment dependent fields for all your environments
+from the production server.
+
+
Important
+
This is an alpha version, the data model and design can change at any time without warning.
+Only for development or testing purpose, do not use in production.
+More details on development status
In order to use this module properly, each environment should have their own encryption key
+and the production environment should have the keys of all environments.
Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us smashing it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/server-env project on GitHub.
"
- alert_string = _("Modify values for {} environment").format(
- current_env
- )
+ alert_string = _("Modify values for {} environment").format(current_env)
alert_type = (
- current_env == config.get("running_env")
- and "alert-info"
- or "alert-warning"
+ current_env == config.get("running_env") and "alert-info" or "alert-warning"
)
elem = etree.fromstring(
"""
@@ -117,20 +111,18 @@ def _set_readonly_form_view(self, doc):
def _update_form_view_from_env(self, arch, view_type):
if view_type != "form":
return arch
- current_env = self.env.context.get("environment") or config.get(
- "running_env"
- )
+ current_env = self.env.context.get("environment") or config.get("running_env")
# Important to keep this list sorted. It makes sure the button to
# switch environment will always be in the same order. (more user
# friendly) and the test would fail without it as the order could
# change randomly and the view would then also change randomly
- other_environments = sorted([
- key[15:]
- for key, val in config.options.items()
- if key.startswith("encryption_key_")
- and val
- and key[15:] != current_env
- ])
+ other_environments = sorted(
+ [
+ key[15:]
+ for key, val in config.options.items()
+ if key.startswith("encryption_key_") and val and key[15:] != current_env
+ ]
+ )
if not current_env:
raise ValidationError(
@@ -143,18 +135,14 @@ def _update_form_view_from_env(self, arch, view_type):
node = doc.xpath("//sheet")
if node:
node = node[0]
- elem = self._get_extra_environment_info_div(
- current_env, other_environments
- )
+ elem = self._get_extra_environment_info_div(current_env, other_environments)
node.insert(0, elem)
if current_env != config.get("running_env"):
self._set_readonly_form_view(doc)
arch = etree.tostring(doc, pretty_print=True, encoding="unicode")
else:
- _logger.error(
- "Missing sheet for form view on object {}".format(self._name)
- )
+ _logger.error("Missing sheet for form view on object {}".format(self._name))
return arch
@api.model
@@ -162,10 +150,7 @@ def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
- view_id=view_id,
- view_type=view_type,
- toolbar=toolbar,
- submenu=submenu,
+ view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu,
)
res["arch"] = self._update_form_view_from_env(res["arch"], view_type)
return res
diff --git a/server_environment_data_encryption/readme/CONFIGURE.rst b/server_environment_data_encryption/readme/CONFIGURE.rst
index 9d0ad4645..37875faa3 100644
--- a/server_environment_data_encryption/readme/CONFIGURE.rst
+++ b/server_environment_data_encryption/readme/CONFIGURE.rst
@@ -1,7 +1,7 @@
In order to use this module properly, each environment should have their own encryption key
-and the production environment should have the keys of all environments.
+and the production environment should have the keys of all environments.
-Example :
+Example :
Development environment ::
[options]
@@ -21,4 +21,3 @@ Production environment ::
encryption_key_dev=XXX
encryption_key_preprod=YYY
encryption_key_prod=ZZZ
-
diff --git a/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
index 4194626a3..d415f70eb 100644
--- a/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
+++ b/server_environment_data_encryption/tests/test_server_environment_data_encrypt.py
@@ -1,11 +1,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from odoo.addons.data_encryption.tests.common import CommonDataEncrypted
from pathlib import Path
+from odoo.addons.data_encryption.tests.common import CommonDataEncrypted
-class TestServerEnvDataEncrypted(CommonDataEncrypted):
+class TestServerEnvDataEncrypted(CommonDataEncrypted):
def test_dynamic_view_current_env(self):
self.maxDiff = None
self.set_new_key_env("prod")
@@ -19,14 +19,15 @@ def test_dynamic_view_current_env(self):
self.assertEqual(res_xml, expected_xml)
def test_dynamic_view_other_env(self):
+ self.maxDiff = None
self.set_new_key_env("prod")
self.set_new_key_env("preprod")
mixin_obj = self.env["server.env.mixin"]
base_path = Path(__file__).parent / "fixtures" / "base.xml"
xml = base_path.read_text()
- res_xml = mixin_obj.with_context(
- environment="prod"
- )._update_form_view_from_env(xml, "form")
+ res_xml = mixin_obj.with_context(environment="prod")._update_form_view_from_env(
+ xml, "form"
+ )
expected_xml_path = Path(__file__).parent / "fixtures" / "res2.xml"
expected_xml = expected_xml_path.read_text()
self.assertEqual(res_xml, expected_xml)
From a687e84e3bfa01afb4ed4b3f1fcba559c138d61f Mon Sep 17 00:00:00 2001
From: Thomas Binsfeld
Date: Mon, 5 Oct 2020 14:07:58 +0200
Subject: [PATCH 09/23] [MIG] server_environment_data_encryption to 13.0
---
server_environment_data_encryption/models/server_env_mixin.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py
index 80261c0ce..5a3c5b973 100644
--- a/server_environment_data_encryption/models/server_env_mixin.py
+++ b/server_environment_data_encryption/models/server_env_mixin.py
@@ -1,9 +1,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+import json
import logging
from lxml import etree
-from odoo.osv.orm import setup_modifiers
from odoo import _, api, models
from odoo.exceptions import ValidationError
@@ -106,7 +106,7 @@ def _set_readonly_form_view(self, doc):
if field_name in env_fields:
continue
field.set("readonly", "1")
- setup_modifiers(field, self.fields_get(field_name))
+ field.set("modifiers", json.dumps({"readonly": True}))
def _update_form_view_from_env(self, arch, view_type):
if view_type != "form":
From f76b6a58fcc6d852af68e5b59d1103665ec848f0 Mon Sep 17 00:00:00 2001
From: Mourad
Date: Mon, 12 Oct 2020 14:07:41 +0200
Subject: [PATCH 10/23] [IMP] server_environment_data_encryption,
data_encryption: black, isort, prettier
---
.../models/server_env_mixin.py | 9 ++--
.../tests/fixtures/base.xml | 21 ++++++---
.../tests/fixtures/res1.xml | 46 +++++++++++++-----
.../tests/fixtures/res2.xml | 47 ++++++++++++++-----
4 files changed, 89 insertions(+), 34 deletions(-)
diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py
index 5a3c5b973..c008577d8 100644
--- a/server_environment_data_encryption/models/server_env_mixin.py
+++ b/server_environment_data_encryption/models/server_env_mixin.py
@@ -32,8 +32,8 @@ def _compute_server_env_from_default(self, field_name, options):
def _inverse_server_env(self, field_name):
"""
- When this module is installed, we store values into encrypted data
- env instead of a default field in database (not env dependent).
+ When this module is installed, we store values into encrypted data
+ env instead of a default field in database (not env dependent).
"""
is_editable_field = self._server_env_is_editable_fieldname(field_name)
encrypted_data_obj = self.env["encrypted.data"].sudo()
@@ -150,7 +150,10 @@ def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
):
res = super().fields_view_get(
- view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu,
+ view_id=view_id,
+ view_type=view_type,
+ toolbar=toolbar,
+ submenu=submenu,
)
res["arch"] = self._update_form_view_from_env(res["arch"], view_type)
return res
diff --git a/server_environment_data_encryption/tests/fixtures/base.xml b/server_environment_data_encryption/tests/fixtures/base.xml
index 524c95993..11f2eb797 100644
--- a/server_environment_data_encryption/tests/fixtures/base.xml
+++ b/server_environment_data_encryption/tests/fixtures/base.xml
@@ -1,15 +1,22 @@
diff --git a/server_environment_data_encryption/tests/fixtures/res1.xml b/server_environment_data_encryption/tests/fixtures/res1.xml
index 7ca515a86..60966da87 100644
--- a/server_environment_data_encryption/tests/fixtures/res1.xml
+++ b/server_environment_data_encryption/tests/fixtures/res1.xml
@@ -1,21 +1,43 @@
diff --git a/server_environment_data_encryption/tests/fixtures/res2.xml b/server_environment_data_encryption/tests/fixtures/res2.xml
index 032e10881..d78832058 100644
--- a/server_environment_data_encryption/tests/fixtures/res2.xml
+++ b/server_environment_data_encryption/tests/fixtures/res2.xml
@@ -1,21 +1,44 @@
From 97f8069c4be66e9d1b2b44f4e93910b7778535ca Mon Sep 17 00:00:00 2001
From: Mourad
Date: Mon, 12 Oct 2020 15:32:19 +0200
Subject: [PATCH 11/23] [MIG] server_environment_data_encryption,
data_encryption: Migration to 14.0
note: exclude tests/fixtures from pre-commit check
---
.../__manifest__.py | 2 +-
.../tests/fixtures/res1.xml | 46 +++++-------------
.../tests/fixtures/res2.xml | 47 +++++--------------
3 files changed, 25 insertions(+), 70 deletions(-)
diff --git a/server_environment_data_encryption/__manifest__.py b/server_environment_data_encryption/__manifest__.py
index ce877483d..c7e8e2258 100644
--- a/server_environment_data_encryption/__manifest__.py
+++ b/server_environment_data_encryption/__manifest__.py
@@ -1,7 +1,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Server Environment Data Encryption",
- "version": "13.0.1.0.0",
+ "version": "14.0.1.0.0",
"development_status": "Alpha",
"category": "Tools",
"website": "https://github.com/OCA/server-env",
diff --git a/server_environment_data_encryption/tests/fixtures/res1.xml b/server_environment_data_encryption/tests/fixtures/res1.xml
index 60966da87..7ca515a86 100644
--- a/server_environment_data_encryption/tests/fixtures/res1.xml
+++ b/server_environment_data_encryption/tests/fixtures/res1.xml
@@ -1,43 +1,21 @@
diff --git a/server_environment_data_encryption/tests/fixtures/res2.xml b/server_environment_data_encryption/tests/fixtures/res2.xml
index d78832058..032e10881 100644
--- a/server_environment_data_encryption/tests/fixtures/res2.xml
+++ b/server_environment_data_encryption/tests/fixtures/res2.xml
@@ -1,44 +1,21 @@
From c9388a5e7349cf0a54da0e773d58da1fefa5eb0f Mon Sep 17 00:00:00 2001
From: oca-travis
Date: Fri, 5 Mar 2021 10:42:51 +0000
Subject: [PATCH 12/23] [UPD] Update server_environment_data_encryption.pot
---
.../server_environment_data_encryption.pot | 31 ++++++++++++++-----
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/server_environment_data_encryption/i18n/server_environment_data_encryption.pot b/server_environment_data_encryption/i18n/server_environment_data_encryption.pot
index 0acf17bc5..ecde6385b 100644
--- a/server_environment_data_encryption/i18n/server_environment_data_encryption.pot
+++ b/server_environment_data_encryption/i18n/server_environment_data_encryption.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * server_environment_data_encryption
+# * server_environment_data_encryption
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -14,25 +14,40 @@ msgstr ""
"Plural-Forms: \n"
#. module: server_environment_data_encryption
-#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:74
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:0
#, python-format
msgid "Define values for "
msgstr ""
+#. module: server_environment_data_encryption
+#: model:ir.model.fields,field_description:server_environment_data_encryption.field_server_env_mixin__display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: server_environment_data_encryption
+#: model:ir.model.fields,field_description:server_environment_data_encryption.field_server_env_mixin__id
+msgid "ID"
+msgstr ""
+
+#. module: server_environment_data_encryption
+#: model:ir.model.fields,field_description:server_environment_data_encryption.field_server_env_mixin____last_update
+msgid "Last Modified on"
+msgstr ""
+
#. module: server_environment_data_encryption
#: model:ir.model,name:server_environment_data_encryption.model_server_env_mixin
msgid "Mixin to add server environment in existing models"
msgstr ""
#. module: server_environment_data_encryption
-#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:86
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:0
#, python-format
msgid "Modify values for {} environment"
msgstr ""
#. module: server_environment_data_encryption
-#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:137
+#: code:addons/server_environment_data_encryption/models/server_env_mixin.py:0
#, python-format
-msgid "you need to define the running_env entry in your odoo configuration file"
+msgid ""
+"you need to define the running_env entry in your odoo configuration file"
msgstr ""
-
From 9051f5fc673120d08118c8f9f452ca9ffc55d1be Mon Sep 17 00:00:00 2001
From: OCA-git-bot
Date: Fri, 5 Mar 2021 10:47:35 +0000
Subject: [PATCH 13/23] [UPD] README.rst
---
server_environment_data_encryption/README.rst | 15 +++++++--------
.../static/description/index.html | 6 +++---
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/server_environment_data_encryption/README.rst b/server_environment_data_encryption/README.rst
index 7b64980bc..4a3f96297 100644
--- a/server_environment_data_encryption/README.rst
+++ b/server_environment_data_encryption/README.rst
@@ -14,13 +14,13 @@ Server Environment Data Encryption
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github
- :target: https://github.com/OCA/server-env/tree/12.0/server_environment_data_encryption
+ :target: https://github.com/OCA/server-env/tree/14.0/server_environment_data_encryption
:alt: OCA/server-env
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/server-env-12-0/server-env-12-0-server_environment_data_encryption
+ :target: https://translation.odoo-community.org/projects/server-env-14-0/server-env-14-0-server_environment_data_encryption
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/254/12.0
+ :target: https://runbot.odoo-community.org/runbot/254/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -46,9 +46,9 @@ Configuration
=============
In order to use this module properly, each environment should have their own encryption key
-and the production environment should have the keys of all environments.
+and the production environment should have the keys of all environments.
-Example :
+Example :
Development environment ::
[options]
@@ -69,14 +69,13 @@ Production environment ::
encryption_key_preprod=YYY
encryption_key_prod=ZZZ
-
Bug Tracker
===========
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -108,6 +107,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/server-env `_ project on GitHub.
+This module is part of the `OCA/server-env `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/server_environment_data_encryption/static/description/index.html b/server_environment_data_encryption/static/description/index.html
index 5bd6658eb..bd00ca030 100644
--- a/server_environment_data_encryption/static/description/index.html
+++ b/server_environment_data_encryption/static/description/index.html
@@ -367,7 +367,7 @@
Server Environment Data Encryption
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module changes a little the behavior of server_environment modules.
When Odoo does not find the value of the field in the configuration file,
it will fallback on a Odoo encrypted field instead.
@@ -424,7 +424,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/server-env project on GitHub.
+
This module is part of the OCA/server-env project on GitHub.