Skip to content

Commit 2d07e0a

Browse files
committed
[MIG] server_environment_data_encryption: Migration to v17.0 (backport from v18)
1 parent 1210871 commit 2d07e0a

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

data_encryption/tests/common.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,33 @@
1414

1515

1616
class CommonDataEncrypted(TransactionCase):
17-
def setUp(self):
18-
super().setUp()
17+
@classmethod
18+
def setUpClass(cls):
19+
super().setUpClass()
1920

20-
self.encrypted_data = self.env["encrypted.data"]
21-
self.set_new_key_env("test")
22-
self.old_running_env = config.get("running_env", "")
21+
cls.encrypted_data = cls.env["encrypted.data"]
22+
cls.set_new_key_env("test")
23+
old_running_env = config.get("running_env", "")
24+
25+
def reset_running_env():
26+
config["running_env"] = old_running_env
27+
28+
cls.addClassCleanup(reset_running_env)
2329
config["running_env"] = "test"
24-
self.crypted_data_name = "test_model,1"
30+
cls.crypted_data_name = "test_model,1"
2531

26-
def set_new_key_env(self, environment):
32+
@classmethod
33+
def set_new_key_env(cls, environment):
2734
crypting_key = Fernet.generate_key()
2835
# The key is encoded to bytes in the module, because in real life
2936
# the key com from the config file and is not in a binary format.
3037
# So we decode here to avoid having a special behavior because of
3138
# the tests.
32-
config[f"encryption_key_{environment}"] = crypting_key.decode()
39+
encryption_key_environment_config_name = f"encryption_key_{environment}"
40+
old_key = config.get(encryption_key_environment_config_name, "")
41+
42+
def reset_config_key():
43+
config[encryption_key_environment_config_name] = old_key
3344

34-
def tearDown(self):
35-
config["running_env"] = self.old_running_env
36-
return super().tearDown()
45+
cls.addClassCleanup(reset_config_key)
46+
config[encryption_key_environment_config_name] = crypting_key.decode()

server_environment_data_encryption/README.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ Server Environment Data Encryption
1010
!! source digest: sha256:d332eb4ca40eb79923ed865b069723db1c2f7be0946a840d9e1cd3197939915e
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
13-
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
1414
:target: https://odoo-community.org/page/development-status
15-
:alt: Production/Stable
15+
:alt: Alpha
1616
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github
20-
:target: https://github.com/OCA/server-env/tree/18.0/server_environment_data_encryption
20+
:target: https://github.com/OCA/server-env/tree/17.0/server_environment_data_encryption
2121
:alt: OCA/server-env
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-server_environment_data_encryption
23+
:target: https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment_data_encryption
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=18.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=17.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -34,6 +34,11 @@ file, it will fallback on a Odoo encrypted field instead. Also it allows
3434
you to configure the environment dependent fields for all your
3535
environments from the production server.
3636

37+
.. IMPORTANT::
38+
This is an alpha version, the data model and design can change at any time without warning.
39+
Only for development or testing purpose, do not use in production.
40+
`More details on development status <https://odoo-community.org/page/development-status>`_
41+
3742
**Table of contents**
3843

3944
.. contents::
@@ -78,7 +83,7 @@ Bug Tracker
7883
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-env/issues>`_.
7984
In case of trouble, please check there if your issue has already been reported.
8085
If you spotted it first, help us to smash it by providing a detailed and welcomed
81-
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment_data_encryption%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
86+
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment_data_encryption%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
8287

8388
Do not contact contributors directly about support or help with technical issues.
8489

@@ -118,6 +123,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
118123

119124
|maintainer-florian-dacosta|
120125

121-
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/18.0/server_environment_data_encryption>`_ project on GitHub.
126+
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/17.0/server_environment_data_encryption>`_ project on GitHub.
122127

123128
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

server_environment_data_encryption/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22
{
33
"name": "Server Environment Data Encryption",
4-
"version": "18.0.1.0.0",
5-
"development_status": "Production/Stable",
4+
"version": "17.0.1.0.0",
5+
"development_status": "Alpha",
66
"maintainers": ["florian-dacosta"],
77
"category": "Tools",
88
"website": "https://github.com/OCA/server-env",

server_environment_data_encryption/models/server_env_mixin.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from lxml import etree
66

7-
from odoo import api, models
7+
from odoo import _, api, models
88
from odoo.exceptions import ValidationError
99
from odoo.tools.config import config
1010

@@ -98,7 +98,7 @@ def _get_extra_environment_info_div(self, current_env, all_environments):
9898
# display a warning instead as the module has no effect.
9999
if not self._current_env_encrypted_key_exists():
100100
button_div = "<div>"
101-
warning_string = self.env._(
101+
warning_string = _(
102102
"The encryption key for current environement is not defined"
103103
)
104104
elem = etree.fromstring(
@@ -119,17 +119,15 @@ def _get_extra_environment_info_div(self, current_env, all_environments):
119119
and "alert-info"
120120
or "alert-warning"
121121
)
122-
alert_string = self.env._("Modify values for {} environment").format(
123-
environment
124-
)
122+
alert_string = _("Modify values for {} environment").format(environment)
125123
elem_string += f"""
126124
<div class="alert lead {alert_type} text-center d-inline"
127125
invisible="context.get('environment', '{current_env}') != '{environment}'">
128126
<strong>{alert_string}</strong>
129127
</div>
130128
"""
131129
button_div = """<div class="d-flex gap-1 flex-wrap align-items-center">"""
132-
button_string = self.env._("Define values for ")
130+
button_string = _("Define values for ")
133131
for environment in all_environments:
134132
button = """
135133
<button name="action_change_env_data_encrypted_fields"
@@ -186,7 +184,7 @@ def _update_form_view_from_env(self, arch, view_type):
186184

187185
if not current_env:
188186
raise ValidationError(
189-
self.env._(
187+
_(
190188
"you need to define the running_env entry in your odoo "
191189
"configuration file"
192190
)

server_environment_data_encryption/static/description/index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,18 @@ <h1 class="title">Server Environment Data Encryption</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:d332eb4ca40eb79923ed865b069723db1c2f7be0946a840d9e1cd3197939915e
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/18.0/server_environment_data_encryption"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-server_environment_data_encryption"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-env&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-env/tree/17.0/server_environment_data_encryption"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment_data_encryption"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-env&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module changes a little the behavior of server_environment modules.
374374
When Odoo does not find the value of the field in the configuration
375375
file, it will fallback on a Odoo encrypted field instead. Also it allows
376376
you to configure the environment dependent fields for all your
377377
environments from the production server.</p>
378+
<div class="admonition important">
379+
<p class="first admonition-title">Important</p>
380+
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
381+
Only for development or testing purpose, do not use in production.
382+
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
383+
</div>
378384
<p><strong>Table of contents</strong></p>
379385
<div class="contents local topic" id="contents">
380386
<ul class="simple">
@@ -419,7 +425,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
419425
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-env/issues">GitHub Issues</a>.
420426
In case of trouble, please check there if your issue has already been reported.
421427
If you spotted it first, help us to smash it by providing a detailed and welcomed
422-
<a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20server_environment_data_encryption%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
428+
<a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20server_environment_data_encryption%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
423429
<p>Do not contact contributors directly about support or help with technical issues.</p>
424430
</div>
425431
<div class="section" id="credits">
@@ -449,7 +455,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
449455
promote its widespread use.</p>
450456
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
451457
<p><a class="reference external image-reference" href="https://github.com/florian-dacosta"><img alt="florian-dacosta" src="https://github.com/florian-dacosta.png?size=40px" /></a></p>
452-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-env/tree/18.0/server_environment_data_encryption">OCA/server-env</a> project on GitHub.</p>
458+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-env/tree/17.0/server_environment_data_encryption">OCA/server-env</a> project on GitHub.</p>
453459
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
454460
</div>
455461
</div>

0 commit comments

Comments
 (0)