Skip to content

Commit

Permalink
[ADD][16.0] fs_document
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrito committed Jan 12, 2024
1 parent 3083166 commit b548da1
Show file tree
Hide file tree
Showing 10 changed files with 547 additions and 0 deletions.
77 changes: 77 additions & 0 deletions fs_document/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/storage/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 <https://github.com/OCA/storage/issues/new?body=module:%20fs_document%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* ERP|OPEN B.V.

Contributors
~~~~~~~~~~~~

Goncalo Brito <[email protected]>

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 <https://github.com/OCA/storage/tree/16.0/fs_document>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions fs_document/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions fs_document/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2024 ERP|OPEN <https://www.erpopen.nl>
# 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,
}
1 change: 1 addition & 0 deletions fs_document/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_binary
21 changes: 21 additions & 0 deletions fs_document/models/ir_binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 ERP|OPEN <https://www.erpopen.nl>
# 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)
1 change: 1 addition & 0 deletions fs_document/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Goncalo Brito <[email protected]>
2 changes: 2 additions & 0 deletions fs_document/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This addon allow the usage of the document app attachments on an external
storage system.
Loading

0 comments on commit b548da1

Please sign in to comment.