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 @@ -Storage Bakend +README.rst -
-

Storage Bakend

+
+ + +Odoo Community Association + +
+

Storage Backend

-

Production/Stable License: LGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

+

Production/Stable License: LGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

+

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

    @@ -383,7 +395,7 @@

    Storage Bakend

-

Bug Tracker

+

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 to smash it by providing a detailed and welcomed @@ -391,15 +403,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Akretion
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -425,5 +437,6 @@

Maintainers

+
diff --git a/storage_backend_environment/README.rst b/storage_backend_environment/README.rst new file mode 100644 index 0000000000..ba21a9d5d2 --- /dev/null +++ b/storage_backend_environment/README.rst @@ -0,0 +1,88 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +==================================== +Storage Backend - Server Environment +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e06faaef8e877cb770756ffc80fe1426d83d0130f6f1c239e9f16995156676ed + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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 + :target: https://github.com/OCA/storage/tree/16.0/storage_backend_environment + :alt: OCA/storage +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/storage-16-0/storage-16-0-storage_backend_environment + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/storage&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module to make Server Environment features available for the storage backend addon. + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Sébastien BEAU +* Raphaël Reverdy +* Florian da Costa +* Cédric Pigeon +* Renato Lima +* Benoît Guillot +* Laurent Mignon +* Denis Roussel +* Maksym Yankin + +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/storage `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/storage_backend_environment/__init__.py b/storage_backend_environment/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/storage_backend_environment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/storage_backend_environment/__manifest__.py b/storage_backend_environment/__manifest__.py new file mode 100644 index 0000000000..4a495073a9 --- /dev/null +++ b/storage_backend_environment/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2017 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Storage Backend - Server Environment", + "summary": "Use Server Environment feature to manage storage backends", + "version": "16.0.1.0.0", + "category": "Storage", + "website": "https://github.com/OCA/storage", + "author": " Akretion, Odoo Community Association (OCA)", + "license": "LGPL-3", + "development_status": "Production/Stable", + "installable": True, + "depends": ["storage_backend", "server_environment"], + "auto_install": True, +} diff --git a/storage_backend_environment/models/__init__.py b/storage_backend_environment/models/__init__.py new file mode 100644 index 0000000000..f45f402268 --- /dev/null +++ b/storage_backend_environment/models/__init__.py @@ -0,0 +1 @@ +from . import storage_backend diff --git a/storage_backend_environment/models/storage_backend.py b/storage_backend_environment/models/storage_backend.py new file mode 100644 index 0000000000..341db4d94f --- /dev/null +++ b/storage_backend_environment/models/storage_backend.py @@ -0,0 +1,25 @@ +# Copyright 2017 Akretion (http://www.akretion.com). +# @author Sébastien BEAU +# Copyright 2019 Camptocamp SA (http://www.camptocamp.com). +# @author Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import models + + +class StorageBackend(models.Model): + _name = "storage.backend" + _inherit = ["storage.backend", "server.env.mixin"] + + def _compute_has_validation(self): + # with server_env + # this code can be triggered + # before a backend_type has been set + # get_adapter() can't work without backend_type + no_type_storage = self.filtered(lambda storage: not storage.backend_type) + no_type_storage.has_validation = False + return super(StorageBackend, self - no_type_storage)._compute_has_validation() + + @property + def _server_env_fields(self): + return {"backend_type": {}, "directory_path": {}} diff --git a/storage_backend_environment/readme/CONTRIBUTORS.rst b/storage_backend_environment/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..2ed110c607 --- /dev/null +++ b/storage_backend_environment/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* Sébastien BEAU +* Raphaël Reverdy +* Florian da Costa +* Cédric Pigeon +* Renato Lima +* Benoît Guillot +* Laurent Mignon +* Denis Roussel +* Maksym Yankin diff --git a/storage_backend_environment/readme/DESCRIPTION.rst b/storage_backend_environment/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..b1735aa71c --- /dev/null +++ b/storage_backend_environment/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Glue module to make Server Environment features available for the storage backend addon. diff --git a/storage_backend_environment/static/description/icon.png b/storage_backend_environment/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/storage_backend_environment/static/description/icon.png differ diff --git a/storage_backend_environment/static/description/index.html b/storage_backend_environment/static/description/index.html new file mode 100644 index 0000000000..6834487849 --- /dev/null +++ b/storage_backend_environment/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Storage Backend - Server Environment

+ +

Production/Stable License: LGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

+

Glue module to make Server Environment features available for the storage backend addon.

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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/storage project on GitHub.

+

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

+
+
+
+
+ +