Skip to content

Commit 0f09e7c

Browse files
committed
[ADD][16.0] fs_document
1 parent 3083166 commit 0f09e7c

6 files changed

Lines changed: 44 additions & 0 deletions

File tree

fs_document/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

fs_document/__manifest__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2024 ERP|OPEN <https://www.erpopen.nl>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
4+
5+
6+
{
7+
"name": "Base Document Attachment Object Store",
8+
"summary": "Enable fetching external stored document.document",
9+
"version": "16.0.1.0.0",
10+
"author": "ERP|OPEN B.V. , Odoo Community Association (OCA)",
11+
"license": "AGPL-3",
12+
"development_status": "Beta",
13+
"category": "Knowledge Management",
14+
"depends": ["documents", "fs_attachment"],
15+
"website": "https://github.com/OCA/storage",
16+
"installable": True,
17+
"auto_install": False,
18+
}

fs_document/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import ir_binary

fs_document/models/ir_binary.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2024 ERP|OPEN <https://www.erpopen.nl>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import models
6+
from odoo.addons.fs_attachment.fs_stream import FsStream
7+
8+
9+
class IrBinary(models.AbstractModel):
10+
_inherit = "ir.binary"
11+
12+
def _record_to_stream(self, record, field_name):
13+
# Extend base implementation to support attachment stored into a
14+
# filesystem storage
15+
if (
16+
record._name == "documents.document"
17+
and field_name in ("raw", "datas", "db_datas")
18+
and record.attachment_id.fs_filename
19+
):
20+
return FsStream.from_fs_attachment(record.attachment_id.sudo())
21+
return super()._record_to_stream(record, field_name)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Goncalo Brito <gbrito@gdsbb.org>

fs_document/readme/DESCRIPTION.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This addon allow the usage of the document app attachments on an external
2+
storage system.

0 commit comments

Comments
 (0)