Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG]dms_attachment_link: port to 16.0 version #311

Closed
12 changes: 6 additions & 6 deletions dms_attachment_link/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dms Attachment Link
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b2c61a3298d158444ea99902b3bc68860d7239f7e9e7a08708201a95fb21a1d
!! source digest: sha256:7d11e23d33bcf0bcc4ec886c80804ce0aa6c270a32ba249fa1f87c425f9c117b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Dms Attachment Link
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
:target: https://github.com/OCA/dms/tree/15.0/dms_attachment_link
:target: https://github.com/OCA/dms/tree/16.0/dms_attachment_link
:alt: OCA/dms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/dms-15-0/dms-15-0-dms_attachment_link
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms_attachment_link
: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/dms&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -54,7 +54,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/dms/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/dms/issues/new?body=module:%20dms_attachment_link%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`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**>`_.

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

Expand Down Expand Up @@ -95,6 +95,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/15.0/dms_attachment_link>`_ project on GitHub.
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/16.0/dms_attachment_link>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 1 addition & 3 deletions dms_attachment_link/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Dms Attachment Link",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Document Management",
"website": "https://github.com/OCA/dms",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand All @@ -14,8 +14,6 @@
"assets": {
"web.assets_backend": [
"dms_attachment_link/static/src/js/dms_attachment_link.esm.js",
],
"web.assets_qweb": [
"dms_attachment_link/static/src/xml/chatter.xml",
],
},
Expand Down
9 changes: 9 additions & 0 deletions dms_attachment_link/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ def _compute_datas(self):
for item in _self:
item.datas = item.dms_file_id.content
return res

@api.model_create_multi
def create(self, vals_list):
"""Create attachments and link them to DMS files."""
attachments = super().create(vals_list)
for attachment, vals in zip(attachments, vals_list):
if "dms_file_id" in vals:
attachment.datas = attachment.dms_file_id.content
return attachments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? The _compute_datas() method already takes care of it (or should).

8 changes: 4 additions & 4 deletions dms_attachment_link/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Dms Attachment Link</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b2c61a3298d158444ea99902b3bc68860d7239f7e9e7a08708201a95fb21a1d
!! source digest: sha256:7d11e23d33bcf0bcc4ec886c80804ce0aa6c270a32ba249fa1f87c425f9c117b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/15.0/dms_attachment_link"><img alt="OCA/dms" src="https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/dms-15-0/dms-15-0-dms_attachment_link"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/dms&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/16.0/dms_attachment_link"><img alt="OCA/dms" src="https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms_attachment_link"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/dms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds a wizard to be able to link an DMS file as an attachment of a document.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -402,7 +402,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/dms/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/dms/issues/new?body=module:%20dms_attachment_link%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="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**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -432,7 +432,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/dms/tree/15.0/dms_attachment_link">OCA/dms</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/dms/tree/16.0/dms_attachment_link">OCA/dms</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
56 changes: 29 additions & 27 deletions dms_attachment_link/static/src/js/dms_attachment_link.esm.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
/** @odoo-module **/

import {AttachmentBox} from "@mail/components/attachment_box/attachment_box";
import {patch} from "web.utils";
import {registerPatch} from "@mail/model/model_core";

patch(
AttachmentBox.prototype,
"dms_attachment_link/static/src/js/dms_attachment_link.js",
{
registerPatch({
name: "AttachmentBoxView",
recordMethods: {
_onAddDmsFile() {
this.env.bus.trigger("do-action", {
action: "dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
options: {
additional_context: {
active_id: this.messaging.models["mail.chatter"].get(
this.props.chatterLocalId
).threadId,
active_ids: [
this.messaging.models["mail.chatter"].get(
this.props.chatterLocalId
).threadId,
],
active_model: this.messaging.models["mail.chatter"].get(
this.props.chatterLocalId
).threadModel,
this.env.services.action.doAction(
"dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link",
{
additionalContext: {
active_id: this.chatter.thread.id,
active_ids: [this.chatter.thread.id],
active_model: this.chatter.threadModel,
},
on_close: this._onAddedDmsFile.bind(this),
},
});
onClose: this._onAddedDmsFile.bind(this),
}
);
},
_onAddedDmsFile() {
this.trigger("reload");
this.chatter.refresh();
},
}
);
},
});

registerPatch({
name: "Chatter",
recordMethods: {
/**
* Handles click on the attach button.
*/
async onClickButtonAddAttachments() {
await this.onClickButtonToggleAttachments();
},
},
});
2 changes: 1 addition & 1 deletion dms_attachment_link/static/src/xml/chatter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<button
class="o_add_dms_file_button btn btn-link"
type="button"
t-on-click.stop.prevent="_onAddDmsFile"
t-on-click.stop.prevent="attachmentBoxView._onAddDmsFile"
>
<i class="fa fa-plus-square" />
Add DMS File
Expand Down
Loading