From 51bdcf25902715aaa17b0bc11076dda700c83824 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 3 Jun 2026 16:12:10 +0200 Subject: [PATCH 01/13] [IMP] fs_storage: Remove dependancy on server_environment --- fs_storage/README.rst | 51 +--------- fs_storage/__manifest__.py | 4 +- .../migrations/16.0.2.0.0/post-migration.py | 16 +++ fs_storage/models/fs_storage.py | 13 --- fs_storage/readme/CONTRIBUTORS.rst | 1 + fs_storage/readme/USAGE.rst | 50 ---------- .../readme/newsfragments/627.feature.rst | 1 + fs_storage/static/description/index.html | 97 +++++-------------- fs_storage/tests/test_fs_storage.py | 7 +- 9 files changed, 52 insertions(+), 188 deletions(-) create mode 100644 fs_storage/migrations/16.0.2.0.0/post-migration.py create mode 100644 fs_storage/readme/newsfragments/627.feature.rst diff --git a/fs_storage/README.rst b/fs_storage/README.rst index 4b0c19a03a..2b8f7d536c 100644 --- a/fs_storage/README.rst +++ b/fs_storage/README.rst @@ -153,56 +153,6 @@ the protocol options as follows: In this example, the SimpleCacheFileSystem protocol will be used as a wrapper around the odoofs protocol. -Server Environment -~~~~~~~~~~~~~~~~~~ - -To ease the management of the filesystem storages configuration accross the different -environments, the configuration of the filesystem storages can be defined in -environment files or directly in the main configuration file. For example, the -configuration of a filesystem storage with the code `fsprod` can be provided in the -main configuration file as follows: - -.. code-block:: ini - - [fs_storage.fsprod] - protocol=s3 - options={"endpoint_url": "https://my_s3_server/", "key": "KEY", "secret": "SECRET"} - directory_path=my_bucket - -To work, a `storage.backend` record must exist with the code `fsprod` into the database. -In your configuration section, you can specify the value for the following fields: - -* `protocol` -* `options` -* `directory_path` - -When evaluating directory_path, `{db_name}` is replaced by the database name. -This is usefull in multi-tenant with a setup completly controlled by -configuration files. - -Migration from storage_backend -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The fs_storage addon can be used to replace the storage_backend addon. (It has -been designed to be a drop-in replacement for the storage_backend addon). To -ease the migration, the `fs.storage` model defines the high-level methods -available in the storage_backend model. These methods are: - -* `add` -* `get` -* `list_files` -* `find_files` -* `move_files` -* `delete` - -These methods are wrappers around the methods of the `fsspec.AbstractFileSystem` -class (see https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem). -These methods are marked as deprecated and will be removed in a future version (V18) -of the addon. You should use the methods of the `fsspec.AbstractFileSystem` class -instead since they are more flexible and powerful. You can access the instance -of the `fsspec.AbstractFileSystem` class using the `fs` property of a `fs.storage` -record. - Known issues / Roadmap ====================== @@ -284,6 +234,7 @@ Contributors * Laurent Mignon * Sébastien BEAU +* Enric Tobella Maintainers ~~~~~~~~~~~ diff --git a/fs_storage/__manifest__.py b/fs_storage/__manifest__.py index e456b8db75..473de7a8b8 100644 --- a/fs_storage/__manifest__.py +++ b/fs_storage/__manifest__.py @@ -5,14 +5,14 @@ { "name": "Filesystem Storage Backend", "summary": "Implement the concept of Storage with amazon S3, sftp...", - "version": "16.0.1.5.0", + "version": "16.0.2.0.0", "category": "FS Storage", "website": "https://github.com/OCA/storage", "author": " ACSONE SA/NV, Odoo Community Association (OCA)", "license": "LGPL-3", "development_status": "Beta", "installable": True, - "depends": ["base", "base_sparse_field", "server_environment"], + "depends": ["base", "base_sparse_field"], "data": [ "views/fs_storage_view.xml", "security/ir.model.access.csv", diff --git a/fs_storage/migrations/16.0.2.0.0/post-migration.py b/fs_storage/migrations/16.0.2.0.0/post-migration.py new file mode 100644 index 0000000000..187a8b0c74 --- /dev/null +++ b/fs_storage/migrations/16.0.2.0.0/post-migration.py @@ -0,0 +1,16 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + if env["ir.module.module"].search( + [("name", "=", "server_environment"), ("state", "=", "installed")] + ): + openupgrade.logged_query( + env.cr, + """ + UPDATE ir_module_module + SET state = 'to install' + WHERE name = 'fs_storage_environment' AND state = 'uninstalled' + """, + ) diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index dbcf36bd03..6fe51fd1b6 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -88,7 +88,6 @@ def wrapper(self, *args, **kwargs): class FSStorage(models.Model): _name = "fs.storage" - _inherit = "server.env.mixin" _description = "FS Storage" __slots__ = ("__fs", "__odoo_storage_path") @@ -203,8 +202,6 @@ def __init__(self, env, ids=(), prefetch_ids=()): ), ] - _server_env_section_name_field = "code" - @api.model def _get_check_connection_method_selection(self): return [ @@ -212,16 +209,6 @@ def _get_check_connection_method_selection(self): ("ls", _("List File")), ] - @property - def _server_env_fields(self): - return { - "protocol": {}, - "options": {}, - "directory_path": {}, - "eval_options_from_env": {}, - "check_connection_method": {}, - } - @api.model_create_multi @prevent_call_from_safe_eval("create") def create(self, vals_list): diff --git a/fs_storage/readme/CONTRIBUTORS.rst b/fs_storage/readme/CONTRIBUTORS.rst index 60c32f1d3f..9c1df66351 100644 --- a/fs_storage/readme/CONTRIBUTORS.rst +++ b/fs_storage/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Laurent Mignon * Sébastien BEAU +* Enric Tobella diff --git a/fs_storage/readme/USAGE.rst b/fs_storage/readme/USAGE.rst index e9f9c25100..6275e9b9f7 100644 --- a/fs_storage/readme/USAGE.rst +++ b/fs_storage/readme/USAGE.rst @@ -46,53 +46,3 @@ the protocol options as follows: In this example, the SimpleCacheFileSystem protocol will be used as a wrapper around the odoofs protocol. - -Server Environment -~~~~~~~~~~~~~~~~~~ - -To ease the management of the filesystem storages configuration accross the different -environments, the configuration of the filesystem storages can be defined in -environment files or directly in the main configuration file. For example, the -configuration of a filesystem storage with the code `fsprod` can be provided in the -main configuration file as follows: - -.. code-block:: ini - - [fs_storage.fsprod] - protocol=s3 - options={"endpoint_url": "https://my_s3_server/", "key": "KEY", "secret": "SECRET"} - directory_path=my_bucket - -To work, a `storage.backend` record must exist with the code `fsprod` into the database. -In your configuration section, you can specify the value for the following fields: - -* `protocol` -* `options` -* `directory_path` - -When evaluating directory_path, `{db_name}` is replaced by the database name. -This is usefull in multi-tenant with a setup completly controlled by -configuration files. - -Migration from storage_backend -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The fs_storage addon can be used to replace the storage_backend addon. (It has -been designed to be a drop-in replacement for the storage_backend addon). To -ease the migration, the `fs.storage` model defines the high-level methods -available in the storage_backend model. These methods are: - -* `add` -* `get` -* `list_files` -* `find_files` -* `move_files` -* `delete` - -These methods are wrappers around the methods of the `fsspec.AbstractFileSystem` -class (see https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem). -These methods are marked as deprecated and will be removed in a future version (V18) -of the addon. You should use the methods of the `fsspec.AbstractFileSystem` class -instead since they are more flexible and powerful. You can access the instance -of the `fsspec.AbstractFileSystem` class using the `fs` property of a `fs.storage` -record. diff --git a/fs_storage/readme/newsfragments/627.feature.rst b/fs_storage/readme/newsfragments/627.feature.rst new file mode 100644 index 0000000000..0107afb987 --- /dev/null +++ b/fs_storage/readme/newsfragments/627.feature.rst @@ -0,0 +1 @@ +- Remove the dependancy of server_environment module and make fs_storage_environment a bridge between fs_storage and server_environment modules. \ No newline at end of file diff --git a/fs_storage/static/description/index.html b/fs_storage/static/description/index.html index ee8e8468a4..3d1b575399 100644 --- a/fs_storage/static/description/index.html +++ b/fs_storage/static/description/index.html @@ -438,24 +438,22 @@

Filesystem Storage Backend