[15.0] [IMP] document_url: upload url from upload activity

Co-authored-by: Jairo Llopis <973709+yajo@users.noreply.github.com>
This commit is contained in:
Emilio Pascual 2023-07-14 17:24:38 +02:00
parent 96ae338925
commit 0058b7878a
No known key found for this signature in database
GPG Key ID: 328505B7DB49BF88
3 changed files with 47 additions and 0 deletions

View File

@ -6,3 +6,4 @@
* Manuel Calero
* Víctor Martínez
* Matias Peralta - Adhoc SA
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)

View File

@ -1,5 +1,6 @@
/** @odoo-module **/
import {Activity} from "@mail/components/activity/activity";
import {AttachmentBox} from "@mail/components/attachment_box/attachment_box";
import {AttachmentCard} from "@mail/components/attachment_card/attachment_card";
import {patch} from "web.utils";
@ -47,3 +48,33 @@ patch(AttachmentCard.prototype, "document_url/static/src/js/url.js", {
});
},
});
patch(Activity.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.activity"].get(
this.props.activityLocalId
).thread.id,
active_ids: [
this.messaging.models["mail.activity"].get(
this.props.activityLocalId
).thread.id,
],
active_model: this.messaging.models["mail.activity"].get(
this.props.activityLocalId
).thread.model,
},
on_close: this._onAddedUrl.bind(this),
},
});
},
async _onAddedUrl() {
await this.activity.markAsDone({attachments: []});
this.trigger("o-attachments-changed");
},
});

View File

@ -54,4 +54,19 @@
</a>
</xpath>
</t>
<t t-inherit="mail.Activity" t-inherit-mode="extension" owl="1">
<xpath
expr="//div[hasclass('o_Activity_tools')]//t[2]/FileUploader"
position="after"
>
<button
type="button"
class="o_Activity_toolButton o_Activity_uploadButton btn btn-link"
t-on-click="_onAddUrl"
>
<i class="fa fa-link" /> Link document by URL</button>
</xpath>
</t>
</templates>