Skip to content

Commit 73145d4

Browse files
committed
Merge PR #371 into 16.0
Signed-off-by pedrobaeza
2 parents 08c573a + a2b7c16 commit 73145d4

23 files changed

+1100
-0
lines changed

dms_attachment_link/README.rst

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
===================
2+
Dms Attachment Link
3+
===================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:7d11e23d33bcf0bcc4ec886c80804ce0aa6c270a32ba249fa1f87c425f9c117b
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
20+
:target: https://github.com/OCA/dms/tree/16.0/dms_attachment_link
21+
:alt: OCA/dms
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms_attachment_link
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a wizard to be able to link an DMS file as an attachment of a document.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Usage
39+
=====
40+
41+
To use this module, you need to:
42+
43+
#. Open the form view of a document (Example: the contact "Azure Interior").
44+
#. Go to the chatter and click on the clip icon.
45+
#. Click **Add DMS File** link.
46+
#. A popup wizard will appear.
47+
#. Search for the desired DMS file (Example: Sydney.jpg) and click on the "Add" button.
48+
#. A new attachment will be created for the document without duplicating
49+
the content.
50+
51+
Bug Tracker
52+
===========
53+
54+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/dms/issues>`_.
55+
In case of trouble, please check there if your issue has already been reported.
56+
If you spotted it first, help us to smash it by providing a detailed and welcomed
57+
`feedback <https://github.com/OCA/dms/issues/new?body=module:%20dms_attachment_link%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
58+
59+
Do not contact contributors directly about support or help with technical issues.
60+
61+
Credits
62+
=======
63+
64+
Authors
65+
~~~~~~~
66+
67+
* Tecnativa
68+
69+
Contributors
70+
~~~~~~~~~~~~
71+
72+
* `Tecnativa <https://www.tecnativa.com>`_
73+
74+
* Pedro M. Baeza
75+
* Víctor Martínez
76+
77+
Maintainers
78+
~~~~~~~~~~~
79+
80+
This module is maintained by the OCA.
81+
82+
.. image:: https://odoo-community.org/logo.png
83+
:alt: Odoo Community Association
84+
:target: https://odoo-community.org
85+
86+
OCA, or the Odoo Community Association, is a nonprofit organization whose
87+
mission is to support the collaborative development of Odoo features and
88+
promote its widespread use.
89+
90+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
91+
:target: https://github.com/victoralmau
92+
:alt: victoralmau
93+
94+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
95+
96+
|maintainer-victoralmau|
97+
98+
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/16.0/dms_attachment_link>`_ project on GitHub.
99+
100+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

dms_attachment_link/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2023 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
{
4+
"name": "Dms Attachment Link",
5+
"version": "16.0.1.0.0",
6+
"category": "Document Management",
7+
"website": "https://github.com/OCA/dms",
8+
"author": "Tecnativa, Odoo Community Association (OCA)",
9+
"license": "AGPL-3",
10+
"depends": ["dms"],
11+
"data": [
12+
"views/dms_file_views.xml",
13+
],
14+
"assets": {
15+
"web.assets_backend": [
16+
"dms_attachment_link/static/src/js/dms_attachment_link.esm.js",
17+
"dms_attachment_link/static/src/xml/chatter.xml",
18+
],
19+
},
20+
"installable": True,
21+
"maintainers": ["victoralmau"],
22+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * dms_attachment_link
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: dms_attachment_link
17+
#: model_terms:ir.ui.view,arch_db:dms_attachment_link.view_dms_file_kanban_wizard_selection
18+
msgid "Add"
19+
msgstr ""
20+
21+
#. module: dms_attachment_link
22+
#. openerp-web
23+
#: code:addons/dms_attachment_link/static/src/xml/chatter.xml:0
24+
#, python-format
25+
msgid "Add DMS File"
26+
msgstr ""
27+
28+
#. module: dms_attachment_link
29+
#: model:ir.model,name:dms_attachment_link.model_ir_attachment
30+
msgid "Attachment"
31+
msgstr ""
32+
33+
#. module: dms_attachment_link
34+
#: model:ir.model.fields,field_description:dms_attachment_link.field_ir_attachment__dms_file_id
35+
msgid "Dms File"
36+
msgstr ""
37+
38+
#. module: dms_attachment_link
39+
#: model:ir.model,name:dms_attachment_link.model_dms_file
40+
msgid "File"
41+
msgstr ""
42+
43+
#. module: dms_attachment_link
44+
#: model:ir.actions.act_window,name:dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link
45+
msgid "Files"
46+
msgstr ""

dms_attachment_link/i18n/es.po

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * dms_attachment_link
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 13.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2023-02-13 07:19+0000\n"
10+
"PO-Revision-Date: 2023-07-28 22:09+0000\n"
11+
"Last-Translator: Ivorra78 <[email protected]>\n"
12+
"Language-Team: \n"
13+
"Language: es\n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
18+
"X-Generator: Weblate 4.17\n"
19+
20+
#. module: dms_attachment_link
21+
#: model_terms:ir.ui.view,arch_db:dms_attachment_link.view_dms_file_kanban_wizard_selection
22+
msgid "Add"
23+
msgstr "Añadir"
24+
25+
#. module: dms_attachment_link
26+
#. openerp-web
27+
#: code:addons/dms_attachment_link/static/src/xml/chatter.xml:0
28+
#, python-format
29+
msgid "Add DMS File"
30+
msgstr "Añadir archivo DMS"
31+
32+
#. module: dms_attachment_link
33+
#: model:ir.model,name:dms_attachment_link.model_ir_attachment
34+
msgid "Attachment"
35+
msgstr "Adjunto"
36+
37+
#. module: dms_attachment_link
38+
#: model:ir.model.fields,field_description:dms_attachment_link.field_ir_attachment__dms_file_id
39+
msgid "Dms File"
40+
msgstr "Archivo Dms"
41+
42+
#. module: dms_attachment_link
43+
#: model:ir.model,name:dms_attachment_link.model_dms_file
44+
msgid "File"
45+
msgstr "Archivo"
46+
47+
#. module: dms_attachment_link
48+
#: model:ir.actions.act_window,name:dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link
49+
msgid "Files"
50+
msgstr "Archivos"

dms_attachment_link/i18n/it.po

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * dms_attachment_link
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"PO-Revision-Date: 2023-10-11 09:37+0000\n"
10+
"Last-Translator: mymage <[email protected]>\n"
11+
"Language-Team: none\n"
12+
"Language: it\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
17+
"X-Generator: Weblate 4.17\n"
18+
19+
#. module: dms_attachment_link
20+
#: model_terms:ir.ui.view,arch_db:dms_attachment_link.view_dms_file_kanban_wizard_selection
21+
msgid "Add"
22+
msgstr "Aggiungi"
23+
24+
#. module: dms_attachment_link
25+
#. openerp-web
26+
#: code:addons/dms_attachment_link/static/src/xml/chatter.xml:0
27+
#, python-format
28+
msgid "Add DMS File"
29+
msgstr "Aggiungi file DMS"
30+
31+
#. module: dms_attachment_link
32+
#: model:ir.model,name:dms_attachment_link.model_ir_attachment
33+
msgid "Attachment"
34+
msgstr "Allegato"
35+
36+
#. module: dms_attachment_link
37+
#: model:ir.model.fields,field_description:dms_attachment_link.field_ir_attachment__dms_file_id
38+
msgid "Dms File"
39+
msgstr "File DMS"
40+
41+
#. module: dms_attachment_link
42+
#: model:ir.model,name:dms_attachment_link.model_dms_file
43+
msgid "File"
44+
msgstr "File"
45+
46+
#. module: dms_attachment_link
47+
#: model:ir.actions.act_window,name:dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link
48+
msgid "Files"
49+
msgstr "File"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import dms_file
2+
from . import ir_attachment
3+
from . import ir_binary
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2023 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import models
5+
6+
7+
class DmsFile(models.Model):
8+
_inherit = "dms.file"
9+
10+
def _prepare_ir_attachment_values(self):
11+
return {
12+
"dms_file_id": self.id,
13+
"name": self.name,
14+
"res_model": self.env.context.get("active_model"),
15+
"res_id": self.env.context.get("active_id"),
16+
}
17+
18+
def action_create_attachment_from_record(self):
19+
return self.env["ir.attachment"].create(self._prepare_ir_attachment_values())
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2023 Tecnativa - Víctor Martínez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class IrAttachment(models.Model):
8+
_inherit = "ir.attachment"
9+
10+
dms_file_id = fields.Many2one(comodel_name="dms.file")
11+
12+
@api.depends("dms_file_id", "dms_file_id.content")
13+
def _compute_datas(self):
14+
"""Get the contents of the attachment directly from the DMS file."""
15+
_self = self.filtered("dms_file_id")
16+
res = super(IrAttachment, (self - _self))._compute_datas()
17+
for item in _self:
18+
item.datas = item.dms_file_id.content
19+
return res
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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)

0 commit comments

Comments
 (0)