From 58e4397a749ebfc152329e2db8dd7bbb5862ea2a Mon Sep 17 00:00:00 2001 From: thien Date: Mon, 14 Oct 2024 15:56:09 +0700 Subject: [PATCH] [MIG] storage_backend: Migration to 18.0 --- storage_backend/README.rst | 7 ++++ storage_backend/__manifest__.py | 2 +- .../components/filesystem_adapter.py | 5 +-- storage_backend/models/storage_backend.py | 40 ++----------------- storage_backend/readme/CONTRIBUTORS.md | 1 + storage_backend/readme/CREDITS.md | 1 + storage_backend/static/description/index.html | 11 ++++- .../views/backend_storage_view.xml | 10 ++--- 8 files changed, 30 insertions(+), 47 deletions(-) create mode 100644 storage_backend/readme/CREDITS.md diff --git a/storage_backend/README.rst b/storage_backend/README.rst index 6413edaf31..40d43c9663 100644 --- a/storage_backend/README.rst +++ b/storage_backend/README.rst @@ -74,6 +74,13 @@ Contributors - Benoît Guillot - Laurent Mignon - Denis Roussel +- Thien Vo + +Other credits +------------- + +The migration of this module from 16.0 to 18.0 was financially supported +by Camptocamp. Maintainers ----------- diff --git a/storage_backend/__manifest__.py b/storage_backend/__manifest__.py index 446a89cd44..3d2055df3b 100644 --- a/storage_backend/__manifest__.py +++ b/storage_backend/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Storage Bakend", "summary": "Implement the concept of Storage with amazon S3, sftp...", - "version": "16.0.1.0.2", + "version": "18.1.0.0.0", "category": "Storage", "website": "https://github.com/OCA/storage", "author": " Akretion, Odoo Community Association (OCA)", diff --git a/storage_backend/components/filesystem_adapter.py b/storage_backend/components/filesystem_adapter.py index 101c3cc286..8bcbc93936 100644 --- a/storage_backend/components/filesystem_adapter.py +++ b/storage_backend/components/filesystem_adapter.py @@ -6,7 +6,6 @@ import os import shutil -from odoo import _ from odoo.exceptions import AccessError from odoo.addons.component.core import Component @@ -31,11 +30,11 @@ def _fullpath(self, relative_path): store the data inside the filestore in the directory 'storage". Becarefull if you implement your own custom path, end user should never be able to write or read unwanted filesystem file""" - full_path = super(FileSystemStorageBackend, self)._fullpath(relative_path) + full_path = super()._fullpath(relative_path) base_dir = self._basedir() full_path = os.path.join(base_dir, full_path) if not is_safe_path(base_dir, full_path): - raise AccessError(_("Access to %s is forbidden") % full_path) + raise AccessError(self.env._("Access to %s is forbidden") % full_path) return full_path def add(self, relative_path, data, **kwargs): diff --git a/storage_backend/models/storage_backend.py b/storage_backend/models/storage_backend.py index 6ad9e051bf..2c4e5af464 100644 --- a/storage_backend/models/storage_backend.py +++ b/storage_backend/models/storage_backend.py @@ -11,7 +11,7 @@ import logging import warnings -from odoo import _, fields, models +from odoo import fields, models _logger = logging.getLogger(__name__) @@ -89,59 +89,27 @@ def add(self, relative_path, data, binary=True, **kwargs): data = base64.b64decode(data) return self._forward("add", relative_path, data, **kwargs) - @deprecated("Use `add`") - def _add_bin_data(self, relative_path, data, **kwargs): - return self.add(relative_path, data, **kwargs) - - @deprecated("Use `add` with `binary=False`") - def _add_b64_data(self, relative_path, data, **kwargs): - return self.add(relative_path, data, binary=False, **kwargs) - def get(self, relative_path, binary=True, **kwargs): data = self._forward("get", relative_path, **kwargs) if not binary and data: data = base64.b64encode(data) return data - @deprecated("Use `get` with `binary=False`") - def _get_b64_data(self, relative_path, **kwargs): - return self.get(relative_path, binary=False, **kwargs) - - @deprecated("Use `get`") - def _get_bin_data(self, relative_path, **kwargs): - return self.get(relative_path, **kwargs) - def list_files(self, relative_path="", pattern=False): names = self._forward("list", relative_path) if pattern: names = fnmatch.filter(names, pattern) return names - @deprecated("Use `list_files`") - def _list(self, relative_path="", pattern=False): - return self.list_files(relative_path, pattern=pattern) - def find_files(self, pattern, relative_path="", **kw): return self._forward("find_files", pattern, relative_path=relative_path) - @deprecated("Use `find_files`") - def _find_files(self, pattern, relative_path="", **kw): - return self.find_files(pattern, relative_path=relative_path, **kw) - def move_files(self, files, destination_path, **kw): return self._forward("move_files", files, destination_path, **kw) - @deprecated("Use `move_files`") - def _move_files(self, files, destination_path, **kw): - return self.move_files(files, destination_path, **kw) - def delete(self, relative_path): return self._forward("delete", relative_path) - @deprecated("Use `delete`") - def _delete(self, relative_path): - return self.delete(relative_path) - def _forward(self, method, *args, **kwargs): _logger.debug( "Backend Storage ID: %s type %s: %s file %s %s", @@ -165,11 +133,11 @@ def action_test_config(self): adapter = self._get_adapter() try: adapter.validate_config() - title = _("Connection Test Succeeded!") - message = _("Everything seems properly set up!") + title = self.env._("Connection Test Succeeded!") + message = self.env._("Everything seems properly set up!") msg_type = "success" except Exception as err: - title = _("Connection Test Failed!") + title = self.env._("Connection Test Failed!") message = str(err) msg_type = "danger" return { diff --git a/storage_backend/readme/CONTRIBUTORS.md b/storage_backend/readme/CONTRIBUTORS.md index ad24cce018..3536a8c91b 100644 --- a/storage_backend/readme/CONTRIBUTORS.md +++ b/storage_backend/readme/CONTRIBUTORS.md @@ -6,3 +6,4 @@ - Benoît Guillot \<\> - Laurent Mignon \<\> - Denis Roussel \<\> +- Thien Vo \<\> diff --git a/storage_backend/readme/CREDITS.md b/storage_backend/readme/CREDITS.md new file mode 100644 index 0000000000..57e03a9fe7 --- /dev/null +++ b/storage_backend/readme/CREDITS.md @@ -0,0 +1 @@ +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp. diff --git a/storage_backend/static/description/index.html b/storage_backend/static/description/index.html index cc7456fffb..a00f4dc985 100644 --- a/storage_backend/static/description/index.html +++ b/storage_backend/static/description/index.html @@ -379,7 +379,8 @@

Storage Bakend

  • Credits
  • @@ -417,10 +418,16 @@

    Contributors

  • Benoît Guillot <benoit.guillot@akretion.com>
  • Laurent Mignon <laurent.mignon@acsone.eu>
  • Denis Roussel <denis.roussel@acsone.eu>
  • +
  • Thien Vo <thienvh@trobz.com>
  • +
    +

    Other credits

    +

    The migration of this module from 16.0 to 18.0 was financially supported +by Camptocamp.

    +