File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from . import dms_file
22from . import ir_attachment
3+ from . import ir_binary
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class IrAttachment(models.Model):
99
1010 dms_file_id = fields .Many2one (comodel_name = "dms.file" )
1111
12- @api .depends ("dms_file_id.content" )
12+ @api .depends ("dms_file_id" , "dms_file_id .content" )
1313 def _compute_datas (self ):
1414 """Get the contents of the attachment directly from the DMS file."""
1515 _self = self .filtered ("dms_file_id" )
Original file line number Diff line number Diff line change 1+ # Copyright 2024 Tecnativa - Víctor Martínez
2+ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
3+
4+ from odoo import models
5+
6+
7+ class IrBinary (models .AbstractModel ):
8+ _inherit = "ir.binary"
9+
10+ def _record_to_stream (self , record , field_name ):
11+ """We need to overwrite for the download and preview to be correct."""
12+ if record ._name == "ir.attachment" and record .dms_file_id :
13+ record = record .dms_file_id
14+ field_name = "content"
15+ return super ()._record_to_stream (record = record , field_name = field_name )
Original file line number Diff line number Diff line change 11# Copyright 2023 Tecnativa - Víctor Martínez
22# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
4- from odoo .tests import common
4+ from odoo .addons . base . tests . common import BaseCommon
55
66
7- class TestDmsAttachmentLink (common .TransactionCase ):
8- def setUp (self ):
9- super ().setUp ()
10- self .partner = self .env ["res.partner" ].create ({"name" : "Test partner" })
11- self .dms_file = self .env .ref ("dms.file_01_demo" )
7+ class TestDmsAttachmentLink (BaseCommon ):
8+ @classmethod
9+ def setUpClass (cls ):
10+ super ().setUpClass ()
11+ cls .partner = cls .env ["res.partner" ].create ({"name" : "Test partner" })
12+ cls .dms_file = cls .env .ref ("dms.file_01_demo" )
1213
1314 def test_add_url_attachment (self ):
1415 attachment = self .dms_file .with_context (
You can’t perform that action at this time.
0 commit comments