Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -425,5 +437,6 @@ diff --git a/setup/storage_backend_environment/odoo/addons/storage_backend_environment b/setup/storage_backend_environment/odoo/addons/storage_backend_environment new file mode 120000 index 0000000000..712fa50db9 --- /dev/null +++ b/setup/storage_backend_environment/odoo/addons/storage_backend_environment @@ -0,0 +1 @@ +../../../../storage_backend_environment \ No newline at end of file diff --git a/setup/storage_backend_environment/setup.py b/setup/storage_backend_environment/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/storage_backend_environment/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/storage_backend/README.rst b/storage_backend/README.rst index 593be987d8..3d70b0f769 100644 --- a/storage_backend/README.rst +++ b/storage_backend/README.rst @@ -1,6 +1,10 @@ -============== -Storage Bakend -============== +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=============== +Storage Backend +=============== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -13,7 +17,7 @@ Storage Bakend .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status :alt: Production/Stable -.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github @@ -28,6 +32,15 @@ Storage Bakend |badge1| |badge2| |badge3| |badge4| |badge5| +This module defines a reusable storage backend model for Odoo. + +It serves as a base layer for modules that need to connect Odoo with external +file storage systems. A backend record centralizes storage configuration and +allows specialized addons to implement support for concrete protocols or +providers such as Amazon S3, SFTP, or compatible services. + +This addon is mainly a technical dependency used by other storage-related +modules. **Table of contents** diff --git a/storage_backend/__manifest__.py b/storage_backend/__manifest__.py index 271fd09787..2eea8f5fd1 100644 --- a/storage_backend/__manifest__.py +++ b/storage_backend/__manifest__.py @@ -3,7 +3,7 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). { - "name": "Storage Bakend", + "name": "Storage Backend", "summary": "Implement the concept of Storage with amazon S3, sftp...", "version": "16.0.1.1.0", "category": "Storage", @@ -12,7 +12,7 @@ "license": "LGPL-3", "development_status": "Production/Stable", "installable": True, - "depends": ["base", "component", "server_environment"], + "depends": ["base", "component"], "data": [ "views/backend_storage_view.xml", "data/data.xml", diff --git a/storage_backend/models/storage_backend.py b/storage_backend/models/storage_backend.py index c678b94319..8f7d499128 100644 --- a/storage_backend/models/storage_backend.py +++ b/storage_backend/models/storage_backend.py @@ -56,7 +56,7 @@ def new_func1(*args, **kwargs): class StorageBackend(models.Model): _name = "storage.backend" - _inherit = ["collection.base", "server.env.mixin"] + _inherit = "collection.base" _backend_name = "storage_backend" _description = "Storage Backend" @@ -71,20 +71,9 @@ class StorageBackend(models.Model): def _compute_has_validation(self): for rec in self: - if not rec.backend_type: - # with server_env - # this code can be triggered - # before a backend_type has been set - # get_adapter() can't work without backend_type - rec.has_validation = False - continue adapter = rec._get_adapter() rec.has_validation = hasattr(adapter, "validate_config") - @property - def _server_env_fields(self): - return {"backend_type": {}, "directory_path": {}} - def add(self, relative_path, data, binary=True, **kwargs): if not binary: data = base64.b64decode(data) @@ -143,6 +132,15 @@ def delete(self, relative_path): def _delete(self, relative_path): return self.delete(relative_path) + def _get_backend_type_default(self): + # get_adapter() can be triggered before a backend_type has been set + # we need to provide a default backend_type to avoid errors in this case + default_backend = self.env.ref( + "storage_backend.default_storage_backend", raise_if_not_found=False + ) + backend_type_default = self.default_get(["backend_type"])["backend_type"] + return default_backend.backend_type or backend_type_default + def _forward(self, method, *args, **kwargs): _logger.debug( "Backend Storage ID: %s type %s: %s file %s %s", @@ -153,6 +151,8 @@ def _forward(self, method, *args, **kwargs): kwargs, ) self.ensure_one() + if not self.backend_type: + self.backend_type = self._get_backend_type_default() adapter = self._get_adapter() return getattr(adapter, method)(*args, **kwargs) diff --git a/storage_backend/readme/DESCRIPTION.rst b/storage_backend/readme/DESCRIPTION.rst index e69de29bb2..d2b093df94 100644 --- a/storage_backend/readme/DESCRIPTION.rst +++ b/storage_backend/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +This module defines a reusable storage backend model for Odoo. + +It serves as a base layer for modules that need to connect Odoo with external +file storage systems. A backend record centralizes storage configuration and +allows specialized addons to implement support for concrete protocols or +providers such as Amazon S3, SFTP, or compatible services. + +This addon is mainly a technical dependency used by other storage-related +modules. diff --git a/storage_backend/static/description/index.html b/storage_backend/static/description/index.html index cbe6c4019e..918fa4dd28 100644 --- a/storage_backend/static/description/index.html +++ b/storage_backend/static/description/index.html @@ -3,7 +3,7 @@
-This module defines a reusable storage backend model for Odoo.
+It serves as a base layer for modules that need to connect Odoo with external +file storage systems. A backend record centralizes storage configuration and +allows specialized addons to implement support for concrete protocols or +providers such as Amazon S3, SFTP, or compatible services.
+This addon is mainly a technical dependency used by other storage-related +modules.
Table of contents
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 to smash it by providing a detailed and welcomed @@ -391,15 +403,15 @@
Do not contact contributors directly about support or help with technical issues.