From 49bed2411950a8a09aee16da45905e72cce3036e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 9 Oct 2024 08:54:30 +0200 Subject: [PATCH] [MIG] dms_attachment_link: Migration to 17.0 TT50055 --- dms_attachment_link/__manifest__.py | 2 +- .../static/src/js/dms_attachment_link.esm.js | 58 +++++++++---------- .../static/src/xml/chatter.xml | 11 ++-- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/dms_attachment_link/__manifest__.py b/dms_attachment_link/__manifest__.py index dcf7d3b43..2df545e42 100644 --- a/dms_attachment_link/__manifest__.py +++ b/dms_attachment_link/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Dms Attachment Link", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "category": "Document Management", "website": "https://github.com/OCA/dms", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/dms_attachment_link/static/src/js/dms_attachment_link.esm.js b/dms_attachment_link/static/src/js/dms_attachment_link.esm.js index 6b8f31e8a..0fc8ab930 100644 --- a/dms_attachment_link/static/src/js/dms_attachment_link.esm.js +++ b/dms_attachment_link/static/src/js/dms_attachment_link.esm.js @@ -1,37 +1,33 @@ /** @odoo-module **/ -import {registerPatch} from "@mail/model/model_core"; +import {Chatter} from "@mail/core/web/chatter"; +import {patch} from "@web/core/utils/patch"; -registerPatch({ - name: "AttachmentBoxView", - recordMethods: { - _onAddDmsFile() { - 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, - }, - onClose: this._onAddedDmsFile.bind(this), - } - ); - }, - _onAddedDmsFile() { - this.chatter.refresh(); - }, +patch(Chatter.prototype, { + _onAddDmsFile() { + this.action.doAction( + "dms_attachment_link.action_dms_file_wizard_selector_dms_attachment_link", + { + additionalContext: { + active_id: this.state.thread.id, + active_ids: [this.state.thread.id], + active_model: this.state.thread.model, + }, + onClose: async () => { + await this._onAddedDmsFile(); + }, + } + ); }, -}); - -registerPatch({ - name: "Chatter", - recordMethods: { - /** - * Handles click on the attach button. - */ - async onClickButtonAddAttachments() { - await this.onClickButtonToggleAttachments(); - }, + onClickAddAttachments(ev) { + ev.stopPropagation(); + this.state.isAttachmentBoxOpened = !this.state.isAttachmentBoxOpened; + if (this.state.isAttachmentBoxOpened) { + this.rootRef.el.scrollTop = 0; + this.state.thread.scrollTop = "bottom"; + } + }, + async _onAddedDmsFile() { + this.reloadParentView(); }, }); diff --git a/dms_attachment_link/static/src/xml/chatter.xml b/dms_attachment_link/static/src/xml/chatter.xml index 187c81dbc..6bd996afa 100644 --- a/dms_attachment_link/static/src/xml/chatter.xml +++ b/dms_attachment_link/static/src/xml/chatter.xml @@ -1,16 +1,13 @@ - - - - - - + +