Skip to content

Commit

Permalink
[MIG] dms_attachment_link: Finish migration
Browse files Browse the repository at this point in the history
[UPD] Update dms_attachment_link.pot
  • Loading branch information
victoralmau committed Oct 9, 2024
1 parent 395f435 commit 50d2472
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
9 changes: 7 additions & 2 deletions dms_attachment_link/i18n/dms_attachment_link.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -19,7 +19,7 @@ msgid "Add"
msgstr ""

#. module: dms_attachment_link
#. openerp-web
#. odoo-javascript
#: code:addons/dms_attachment_link/static/src/xml/chatter.xml:0
#, python-format
msgid "Add DMS File"
Expand All @@ -40,6 +40,11 @@ msgstr ""
msgid "File"
msgstr ""

#. module: dms_attachment_link
#: model:ir.model,name:dms_attachment_link.model_ir_binary
msgid "File streaming helper model for controllers"
msgstr ""

#. module: dms_attachment_link
#: model:ir.actions.act_window,name:dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link
msgid "Files"
Expand Down
1 change: 1 addition & 0 deletions dms_attachment_link/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import dms_file
from . import ir_attachment
from . import ir_binary
2 changes: 1 addition & 1 deletion dms_attachment_link/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class IrAttachment(models.Model):

dms_file_id = fields.Many2one(comodel_name="dms.file")

@api.depends("dms_file_id.content")
@api.depends("dms_file_id", "dms_file_id.content")
def _compute_datas(self):
"""Get the contents of the attachment directly from the DMS file."""
_self = self.filtered("dms_file_id")
Expand Down
15 changes: 15 additions & 0 deletions dms_attachment_link/models/ir_binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models


class IrBinary(models.AbstractModel):
_inherit = "ir.binary"

def _record_to_stream(self, record, field_name):
"""We need to overwrite for the download and preview to be correct."""
if record._name == "ir.attachment" and record.dms_file_id:
record = record.dms_file_id
field_name = "content"
return super()._record_to_stream(record=record, field_name=field_name)
13 changes: 7 additions & 6 deletions dms_attachment_link/tests/test_dms_attachment_link.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import common
from odoo.addons.base.tests.common import BaseCommon


class TestDmsAttachmentLink(common.TransactionCase):
def setUp(self):
super().setUp()
self.partner = self.env["res.partner"].create({"name": "Test partner"})
self.dms_file = self.env.ref("dms.file_01_demo")
class TestDmsAttachmentLink(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env["res.partner"].create({"name": "Test partner"})
cls.dms_file = cls.env.ref("dms.file_01_demo")

def test_add_url_attachment(self):
attachment = self.dms_file.with_context(
Expand Down

0 comments on commit 50d2472

Please sign in to comment.