From 0eb189f1c4bdf63fa44cfe13b29861f66b906cc9 Mon Sep 17 00:00:00 2001 From: jb Date: Mon, 4 Apr 2022 12:54:11 +0200 Subject: [PATCH] [MIG] mail_quoted_reply: Migration to 14.0 --- mail_quoted_reply/__manifest__.py | 7 ++- .../src/components/mail_message_reply.js | 20 +++++++ .../static/src/js/mail_message_reply.js | 60 ------------------- .../static/src/models/mail_message_reply.js | 34 +++++++++++ .../src/scss/thread_mail_message_reply.scss | 21 +++++++ .../static/src/xml/mail_message_reply.xml | 24 ++++---- mail_quoted_reply/templates/assets.xml | 11 +++- .../odoo/addons/mail_quoted_reply | 1 + setup/mail_quoted_reply/setup.py | 6 ++ 9 files changed, 110 insertions(+), 74 deletions(-) create mode 100644 mail_quoted_reply/static/src/components/mail_message_reply.js delete mode 100644 mail_quoted_reply/static/src/js/mail_message_reply.js create mode 100644 mail_quoted_reply/static/src/models/mail_message_reply.js create mode 100644 mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss create mode 120000 setup/mail_quoted_reply/odoo/addons/mail_quoted_reply create mode 100644 setup/mail_quoted_reply/setup.py diff --git a/mail_quoted_reply/__manifest__.py b/mail_quoted_reply/__manifest__.py index 106b444..b001a9a 100644 --- a/mail_quoted_reply/__manifest__.py +++ b/mail_quoted_reply/__manifest__.py @@ -5,11 +5,14 @@ "name": "Mail Message Reply", "summary": """ Make a reply using a message""", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "license": "AGPL-3", "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/social", "depends": ["mail"], "qweb": ["static/src/xml/mail_message_reply.xml"], - "data": ["templates/assets.xml", "data/reply_template.xml"], + "data": [ + "templates/assets.xml", + "data/reply_template.xml", + ], } diff --git a/mail_quoted_reply/static/src/components/mail_message_reply.js b/mail_quoted_reply/static/src/components/mail_message_reply.js new file mode 100644 index 0000000..da29add --- /dev/null +++ b/mail_quoted_reply/static/src/components/mail_message_reply.js @@ -0,0 +1,20 @@ +odoo.define("mail_quoted_reply/static/src/components/mail_message_reply.js", function ( + require +) { + "use strict"; + + const components = { + Message: require("mail/static/src/components/message/message.js"), + }; + const {patch} = require("web.utils"); + + patch( + components.Message, + "mail_quoted_reply/static/src/models/mail_message_reply.js", + { + _onClickMailMessageReply() { + this.message._onClickMailMessageReply(); + }, + } + ); +}); diff --git a/mail_quoted_reply/static/src/js/mail_message_reply.js b/mail_quoted_reply/static/src/js/mail_message_reply.js deleted file mode 100644 index 8f9fc13..0000000 --- a/mail_quoted_reply/static/src/js/mail_message_reply.js +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2021 Creu Blanca - * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - */ -odoo.define("mail_quote_reply.reply", function(require) { - "use strict"; - - var ThreadWidget = require("mail.widget.Thread"); - var ThreadField = require("mail.ThreadField"); - var DocumentThread = require("mail.model.DocumentThread"); - - DocumentThread.include({ - _fetchMessages: function(options) { - if (options && options.forceReloadMessages) { - this._mustFetchMessageIDs = true; - } - return this._super.apply(this, arguments); - }, - }); - - ThreadField.include({ - start: function() { - var self = this; - return this._super.apply(this, arguments).then(function() { - self._threadWidget.on( - "reload_thread_messages", - self, - self._onReloadThreadMessages - ); - }); - }, - _onReloadThreadMessages: function() { - this._fetchAndRenderThread({forceReloadMessages: true}); - }, - }); - - ThreadWidget.include({ - events: _.defaults( - { - "click .o_thread_mail_message_reply": "_onClickMailMessageReply", - }, - ThreadWidget.prototype.events - ), - - _onClickMailMessageReply: function(event) { - var self = this, - msg_id = $(event.currentTarget).data("message-id"); - this._rpc({ - model: "mail.message", - method: "reply_message", - args: [msg_id], - }).then(function(result) { - self.do_action(result, { - on_close: function() { - self.trigger("reload_thread_messages"); - }, - }); - }); - }, - }); -}); diff --git a/mail_quoted_reply/static/src/models/mail_message_reply.js b/mail_quoted_reply/static/src/models/mail_message_reply.js new file mode 100644 index 0000000..005c818 --- /dev/null +++ b/mail_quoted_reply/static/src/models/mail_message_reply.js @@ -0,0 +1,34 @@ +odoo.define("mail_quoted_reply/static/src/models/mail_message_reply.js", function ( + require +) { + "use strict"; + + const {registerInstancePatchModel} = require("mail/static/src/model/model_core.js"); + + registerInstancePatchModel( + "mail.message", + "mail_quoted_reply/static/src/models/mail_message_reply.js", + { + _onClickMailMessageReply: function () { + var self = this, + msg_id = this.id; + this.env.services + .rpc({ + model: "mail.message", + method: "reply_message", + args: [msg_id], + }) + .then(function (result) { + self.env.bus.trigger("do-action", { + action: result, + options: { + on_close: () => { + self.originThread.refresh(); + }, + }, + }); + }); + }, + } + ); +}); diff --git a/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss b/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss new file mode 100644 index 0000000..0d3acbe --- /dev/null +++ b/mail_quoted_reply/static/src/scss/thread_mail_message_reply.scss @@ -0,0 +1,21 @@ +.o_thread_mail_message_reply { + cursor: pointer; + color: gray("400"); + &:not(.o-mobile) { + &:hover { + filter: brightness(0.8); + } + } + + &.o-mobile { + filter: brightness(0.8); + + &:hover { + filter: brightness(0.75); + } + } + + &.o-message-selected { + color: gray("500"); + } +} diff --git a/mail_quoted_reply/static/src/xml/mail_message_reply.xml b/mail_quoted_reply/static/src/xml/mail_message_reply.xml index fc4b135..ccf41ab 100644 --- a/mail_quoted_reply/static/src/xml/mail_message_reply.xml +++ b/mail_quoted_reply/static/src/xml/mail_message_reply.xml @@ -2,16 +2,18 @@ diff --git a/mail_quoted_reply/templates/assets.xml b/mail_quoted_reply/templates/assets.xml index b53fdf6..98b0ffd 100644 --- a/mail_quoted_reply/templates/assets.xml +++ b/mail_quoted_reply/templates/assets.xml @@ -12,7 +12,16 @@