[FIX] document_url: Migration was not done properly

This commit is contained in:
Enric Tobella 2023-06-06 09:31:41 +02:00 committed by Bhavesh Heliconia
parent ab87e3e499
commit a6e79f21de
4 changed files with 44 additions and 54 deletions

View File

@ -15,9 +15,8 @@
"assets": { "assets": {
"web.assets_backend": [ "web.assets_backend": [
"document_url/static/src/js/url.esm.js", "document_url/static/src/js/url.esm.js",
],
"web.assets_qweb": [
"document_url/static/src/xml/url.xml", "document_url/static/src/xml/url.xml",
"document_url/static/src/scss/document_url.scss",
], ],
}, },
"installable": True, "installable": True,

View File

@ -3,33 +3,28 @@
import {AttachmentBox} from "@mail/components/attachment_box/attachment_box"; import {AttachmentBox} from "@mail/components/attachment_box/attachment_box";
import {AttachmentCard} from "@mail/components/attachment_card/attachment_card"; import {AttachmentCard} from "@mail/components/attachment_card/attachment_card";
import {patch} from "web.utils"; import {patch} from "web.utils";
import {url} from "@web/core/utils/urls";
patch(AttachmentBox.prototype, "document_url/static/src/js/url.js", { patch(AttachmentBox.prototype, "document_url/static/src/js/url.js", {
_onAddUrl(event) { _onAddUrl(event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
this.env.bus.trigger("do-action", { if (this.env.model) {
action: "document_url.action_ir_attachment_add_url", this.env.services.action.doAction(
options: { "document_url.action_ir_attachment_add_url",
additional_context: { {
active_id: this.messaging.models["mail.chatter"].get( additionalContext: {
this.props.chatterLocalId active_id: this.env.model.root.data.id,
).threadId, active_ids: [this.env.model.root.data.id],
active_ids: [ active_model: this.env.model.root.resModel,
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), onClose: this._onAddedUrl.bind(this),
}, }
}); );
}
}, },
_onAddedUrl() { _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} * @returns {String}
*/ */
get attachmentUrl() { get attachmentUrl() {
return this.env.session.url("/web/content", { return url("/web/content", {
id: this.attachmentCard.attachment.id, id: this.attachmentCard.attachment.id,
download: true, download: true,
}); });

View File

@ -1,15 +1,8 @@
.o_AttachmentBox_content { .o_image.o_Attachment_url_ico {
text-align: center; background-image: none;
i {
display: block; display: block;
} text-align: center;
.o_AttachmentList_partialListNonImages { line-height: revert;
.o_Attachment_image {
cursor: pointer;
}
.o_Attachment_filename a {
color: #4c4c4c;
} }
} }
.o_Attachment_url_icon {
margin: 4px 2px 0px 4px;
}

View File

@ -3,6 +3,7 @@
Copyright 2021 Tecnativa - Víctor Martínez Copyright 2021 Tecnativa - Víctor Martínez
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates> <templates>
<t t-inherit="mail.AttachmentBox" t-inherit-mode="extension" owl="1"> <t t-inherit="mail.AttachmentBox" t-inherit-mode="extension" owl="1">
<xpath <xpath
expr="//button[hasclass('o_AttachmentBox_buttonAdd')]" expr="//button[hasclass('o_AttachmentBox_buttonAdd')]"
@ -12,10 +13,11 @@
<button <button
class="o_AttachmentBox_buttonAdd btn btn-link" class="o_AttachmentBox_buttonAdd btn btn-link"
type="button" type="button"
t-on-click="_onClickAdd" t-on-click="attachmentBoxView.onClickAddAttachment"
t-att-disabled="!attachmentBoxView.chatter.isTemporary and !attachmentBoxView.chatter.hasWriteAccess"
> >
<i class="fa fa-plus-square" /> <i class="fa fa-plus-square" />
Add attachments Attach files
</button> </button>
<button <button
type="button" type="button"
@ -28,29 +30,30 @@
</div> </div>
</xpath> </xpath>
</t> </t>
<t t-inherit="mail.AttachmentCard" t-inherit-mode="extension" owl="1"> <t t-inherit="mail.AttachmentCard" t-inherit-mode="extension" owl="1">
<xpath <xpath
expr="//div[hasclass('o_AttachmentCard_details')]/t/div" expr="//button[hasclass('o_AttachmentCard_asideItemDownload')]"
position="replace"
>
<a t-att-href="attachmentUrl" target="new">
<t t-esc="attachmentCard.attachment.displayName" />
</a>
</xpath>
<xpath
expr="//div[hasclass('o_AttachmentCard_details')]/t[2]/div"
position="replace"
>
</xpath>
<xpath
expr="//div[hasclass('o_AttachmentCard_asideItemDownload')]"
position="attributes" position="attributes"
> >
<attribute <attribute
name="t-if" name="t-if"
>attachmentCard.attachment.mimetype != 'application/link'</attribute> >attachmentCard.attachment.mimetype != 'application/link'</attribute>
</xpath> </xpath>
<xpath
expr="//button[hasclass('o_AttachmentCard_asideItemDownload')]"
position="after"
>
<button
class="o_AttachmentCard_asideItem o_AttachmentCard_asideItemDownload btn d-flex justify-content-center align-items-center w-100 h-100 rounded-0 bg-300"
t-on-click="() => window.open(attachmentUrl, '_blank')"
title="Open"
t-if="attachmentCard.attachment.mimetype === 'application/link'"
target="new"
>
<i class="fa fa-link" role="img" aria-label="Open" />
</button>
</xpath>
<xpath expr="//div[hasclass('o_AttachmentCard_image')]" position="attributes"> <xpath expr="//div[hasclass('o_AttachmentCard_image')]" position="attributes">
<attribute <attribute
name="t-if" name="t-if"
@ -58,7 +61,7 @@
</xpath> </xpath>
<xpath expr="//div[hasclass('o_AttachmentCard_image')]" position="before"> <xpath expr="//div[hasclass('o_AttachmentCard_image')]" position="before">
<a <a
class="o_Attachment_url_icon" class="o_Attachment_url_ico o_image flex-shrink-0 m-1"
t-att-href="attachmentUrl" t-att-href="attachmentUrl"
target="new" target="new"
t-if="attachmentCard.attachment.mimetype=='application/link'" t-if="attachmentCard.attachment.mimetype=='application/link'"