From b548da18b49bfda827a46d135e59e2202d9026b9 Mon Sep 17 00:00:00 2001 From: Goncalo Brito Date: Fri, 12 Jan 2024 16:19:46 +0100 Subject: [PATCH] [ADD][16.0] fs_document --- fs_document/README.rst | 77 ++++ fs_document/__init__.py | 1 + fs_document/__manifest__.py | 17 + fs_document/models/__init__.py | 1 + fs_document/models/ir_binary.py | 21 ++ fs_document/readme/CONTRIBUTORS.rst | 1 + fs_document/readme/DESCRIPTION.rst | 2 + fs_document/static/description/index.html | 420 ++++++++++++++++++++++ setup/fs_document/odoo/addons/fs_document | 1 + setup/fs_document/setup.py | 6 + 10 files changed, 547 insertions(+) create mode 100644 fs_document/README.rst create mode 100644 fs_document/__init__.py create mode 100644 fs_document/__manifest__.py create mode 100644 fs_document/models/__init__.py create mode 100644 fs_document/models/ir_binary.py create mode 100644 fs_document/readme/CONTRIBUTORS.rst create mode 100644 fs_document/readme/DESCRIPTION.rst create mode 100644 fs_document/static/description/index.html create mode 120000 setup/fs_document/odoo/addons/fs_document create mode 100644 setup/fs_document/setup.py diff --git a/fs_document/README.rst b/fs_document/README.rst new file mode 100644 index 0000000000..08ff6809a9 --- /dev/null +++ b/fs_document/README.rst @@ -0,0 +1,77 @@ +===================================== +Base Document Attachment Object Store +===================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d6a9ffc01c8fc6c6ee93edd0dd763a673d955028b2819df121acc1a45f80af8e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github + :target: https://github.com/OCA/storage/tree/16.0/fs_document + :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-fs_document + :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| + +This addon allow the usage of the document app attachments on an external +storage system. + +**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 +~~~~~~~ + +* ERP|OPEN B.V. + +Contributors +~~~~~~~~~~~~ + +Goncalo Brito + +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/fs_document/__init__.py b/fs_document/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/fs_document/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/fs_document/__manifest__.py b/fs_document/__manifest__.py new file mode 100644 index 0000000000..846283331b --- /dev/null +++ b/fs_document/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (c) 2024 ERP|OPEN +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + + +{ + "name": "Base Document Attachment Object Store", + "summary": "Enable fetching external stored document.document", + "version": "16.0.1.0.0", + "author": "ERP|OPEN B.V. , Odoo Community Association (OCA)", + "license": "AGPL-3", + "development_status": "Beta", + "category": "Knowledge Management", + "depends": ["documents", "fs_attachment"], + "website": "https://github.com/OCA/storage", + "installable": True, + "auto_install": False, +} diff --git a/fs_document/models/__init__.py b/fs_document/models/__init__.py new file mode 100644 index 0000000000..0ad7071016 --- /dev/null +++ b/fs_document/models/__init__.py @@ -0,0 +1 @@ +from . import ir_binary diff --git a/fs_document/models/ir_binary.py b/fs_document/models/ir_binary.py new file mode 100644 index 0000000000..5d84519fd6 --- /dev/null +++ b/fs_document/models/ir_binary.py @@ -0,0 +1,21 @@ +# Copyright (c) 2024 ERP|OPEN +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + +from odoo.addons.fs_attachment.fs_stream import FsStream + + +class IrBinary(models.AbstractModel): + _inherit = "ir.binary" + + def _record_to_stream(self, record, field_name): + # Extend base implementation to support attachment stored into a + # filesystem storage + if ( + record._name == "documents.document" + and field_name in ("raw", "datas", "db_datas") + and record.attachment_id.fs_filename + ): + return FsStream.from_fs_attachment(record.attachment_id.sudo()) + return super()._record_to_stream(record, field_name) diff --git a/fs_document/readme/CONTRIBUTORS.rst b/fs_document/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..0fa6348e3c --- /dev/null +++ b/fs_document/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +Goncalo Brito diff --git a/fs_document/readme/DESCRIPTION.rst b/fs_document/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..61c404cc43 --- /dev/null +++ b/fs_document/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This addon allow the usage of the document app attachments on an external +storage system. diff --git a/fs_document/static/description/index.html b/fs_document/static/description/index.html new file mode 100644 index 0000000000..88e4b75927 --- /dev/null +++ b/fs_document/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Base Document Attachment Object Store + + + +
+

Base Document Attachment Object Store

+ + +

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

+

This addon allow the usage of the document app attachments on an external +storage system.

+

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

+
    +
  • ERP|OPEN B.V.
  • +
+
+
+

Contributors

+

Goncalo Brito <gbrito@gdsbb.org>

+
+
+

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.

+
+
+
+ + diff --git a/setup/fs_document/odoo/addons/fs_document b/setup/fs_document/odoo/addons/fs_document new file mode 120000 index 0000000000..4db26e4ce4 --- /dev/null +++ b/setup/fs_document/odoo/addons/fs_document @@ -0,0 +1 @@ +../../../../fs_document \ No newline at end of file diff --git a/setup/fs_document/setup.py b/setup/fs_document/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fs_document/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)