From e080dc24ec34350ff3298c7c289ad7b8ce41846f Mon Sep 17 00:00:00 2001 From: angelinaanaki Date: Wed, 12 Jul 2023 17:23:26 +0200 Subject: [PATCH] [16.0][FIX] document_url: Add URL button and paperclip button --- document_url/static/src/js/url.esm.js | 27 ++++++++++++++------------- document_url/static/src/xml/url.xml | 14 +++++++++++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/document_url/static/src/js/url.esm.js b/document_url/static/src/js/url.esm.js index 7a92a8e1..0ccda253 100644 --- a/document_url/static/src/js/url.esm.js +++ b/document_url/static/src/js/url.esm.js @@ -1,30 +1,31 @@ /** @odoo-module **/ -import {AttachmentBox} from "@mail/components/attachment_box/attachment_box"; +import {registerPatch} from "@mail/model/model_core"; 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(); - if (this.env.model) { +registerPatch({ + name: "AttachmentBoxView", + recordMethods: { + _onAddUrl(event) { + event.preventDefault(); + event.stopPropagation(); 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, + active_id: this.chatter.thread.id, + active_ids: [this.chatter.thread.id], + active_model: this.chatter.thread.model, }, onClose: this._onAddedUrl.bind(this), } ); - } - }, - _onAddedUrl() { - this.props.record.chatter.refresh(); + }, + _onAddedUrl() { + this.chatter.refresh(); + }, }, }); diff --git a/document_url/static/src/xml/url.xml b/document_url/static/src/xml/url.xml index 2c8f3aa7..4e75a91d 100644 --- a/document_url/static/src/xml/url.xml +++ b/document_url/static/src/xml/url.xml @@ -22,7 +22,7 @@