From a6e79f21de402e2b5d5600e07f43df57871019c8 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 6 Jun 2023 09:31:41 +0200 Subject: [PATCH] [FIX] document_url: Migration was not done properly --- document_url/__manifest__.py | 3 +- document_url/static/src/js/url.esm.js | 37 ++++++++---------- .../static/src/scss/document_url.scss | 19 +++------ document_url/static/src/xml/url.xml | 39 ++++++++++--------- 4 files changed, 44 insertions(+), 54 deletions(-) diff --git a/document_url/__manifest__.py b/document_url/__manifest__.py index 7085c820..638045f8 100644 --- a/document_url/__manifest__.py +++ b/document_url/__manifest__.py @@ -15,9 +15,8 @@ "assets": { "web.assets_backend": [ "document_url/static/src/js/url.esm.js", - ], - "web.assets_qweb": [ "document_url/static/src/xml/url.xml", + "document_url/static/src/scss/document_url.scss", ], }, "installable": True, diff --git a/document_url/static/src/js/url.esm.js b/document_url/static/src/js/url.esm.js index 99f5a4fb..7a92a8e1 100644 --- a/document_url/static/src/js/url.esm.js +++ b/document_url/static/src/js/url.esm.js @@ -3,33 +3,28 @@ import {AttachmentBox} from "@mail/components/attachment_box/attachment_box"; import {AttachmentCard} from "@mail/components/attachment_card/attachment_card"; import {patch} from "web.utils"; +import {url} from "@web/core/utils/urls"; patch(AttachmentBox.prototype, "document_url/static/src/js/url.js", { _onAddUrl(event) { event.preventDefault(); event.stopPropagation(); - this.env.bus.trigger("do-action", { - action: "document_url.action_ir_attachment_add_url", - 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, - }, - on_close: this._onAddedUrl.bind(this), - }, - }); + if (this.env.model) { + this.env.services.action.doAction( + "document_url.action_ir_attachment_add_url", + { + additionalContext: { + active_id: this.env.model.root.data.id, + active_ids: [this.env.model.root.data.id], + active_model: this.env.model.root.resModel, + }, + onClose: this._onAddedUrl.bind(this), + } + ); + } }, _onAddedUrl() { - this.trigger("reload"); + this.props.record.chatter.refresh(); }, }); @@ -41,7 +36,7 @@ patch(AttachmentCard.prototype, "document_url/static/src/js/url.js", { * @returns {String} */ get attachmentUrl() { - return this.env.session.url("/web/content", { + return url("/web/content", { id: this.attachmentCard.attachment.id, download: true, }); diff --git a/document_url/static/src/scss/document_url.scss b/document_url/static/src/scss/document_url.scss index 3b8b69a5..8ea2bbed 100644 --- a/document_url/static/src/scss/document_url.scss +++ b/document_url/static/src/scss/document_url.scss @@ -1,15 +1,8 @@ -.o_AttachmentBox_content { - text-align: center; - display: block; -} -.o_AttachmentList_partialListNonImages { - .o_Attachment_image { - cursor: pointer; - } - .o_Attachment_filename a { - color: #4c4c4c; +.o_image.o_Attachment_url_ico { + background-image: none; + i { + display: block; + text-align: center; + line-height: revert; } } -.o_Attachment_url_icon { - margin: 4px 2px 0px 4px; -} diff --git a/document_url/static/src/xml/url.xml b/document_url/static/src/xml/url.xml index b0855c3a..2c8f3aa7 100644 --- a/document_url/static/src/xml/url.xml +++ b/document_url/static/src/xml/url.xml @@ -3,6 +3,7 @@ Copyright 2021 Tecnativa - Víctor Martínez License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + - Add attachments + Attach files + +