From c3326b92cce66353f8946b3ded0e5dc10c055625 Mon Sep 17 00:00:00 2001 From: "Atchuthan, Sodexis" Date: Fri, 22 Jan 2021 15:06:00 +0530 Subject: [PATCH] [MIG] mail_activity_board: Migration to 14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [FIX] add title to tag and removed console.log in js Co-authored-by: Miquel Raïch Co-authored-by: Miquel Raïch --- mail_activity_board/__manifest__.py | 7 ++- mail_activity_board/models/mail_activity.py | 2 +- .../models/mail_activity_mixin.py | 4 +- mail_activity_board/readme/CONTRIBUTORS.rst | 4 +- .../chatter_topbar/chatter_topbar.js | 57 +++++++++++++++++++ .../chatter_topbar/chatter_topbar.xml | 19 +++++++ .../static/src/js/override_chatter.js | 31 ---------- .../static/src/xml/inherit_chatter.xml | 18 ------ .../views/mail_activity_view.xml | 6 +- mail_activity_board/views/templates.xml | 2 +- 10 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js create mode 100644 mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml delete mode 100644 mail_activity_board/static/src/js/override_chatter.js delete mode 100644 mail_activity_board/static/src/xml/inherit_chatter.xml diff --git a/mail_activity_board/__manifest__.py b/mail_activity_board/__manifest__.py index 4feddae..06ec8cd 100644 --- a/mail_activity_board/__manifest__.py +++ b/mail_activity_board/__manifest__.py @@ -1,16 +1,17 @@ # Copyright 2018 David Juaneda - +# Copyright 2021 Sodexis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Mail Activity Board", "summary": "Add Activity Boards", - "version": "13.0.1.0.1", + "version": "14.0.1.0.0", "development_status": "Beta", "category": "Social Network", "website": "https://github.com/OCA/social", - "author": "SDi, David Juaneda, Odoo Community Association (OCA)", + "author": "SDi, David Juaneda, Sodexis, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "depends": ["calendar", "board"], "data": ["views/templates.xml", "views/mail_activity_view.xml"], - "qweb": ["static/src/xml/inherit_chatter.xml"], + "qweb": ["static/src/components/chatter_topbar/chatter_topbar.xml"], } diff --git a/mail_activity_board/models/mail_activity.py b/mail_activity_board/models/mail_activity.py index f1378ca..573ab22 100644 --- a/mail_activity_board/models/mail_activity.py +++ b/mail_activity_board/models/mail_activity.py @@ -1,5 +1,5 @@ # Copyright 2018 David Juaneda - -# Copyright 2018 Eficent Business and IT Consulting Services, S.L. +# Copyright 2018 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models diff --git a/mail_activity_board/models/mail_activity_mixin.py b/mail_activity_board/models/mail_activity_mixin.py index 5ab4ede..2f526e4 100644 --- a/mail_activity_board/models/mail_activity_mixin.py +++ b/mail_activity_board/models/mail_activity_mixin.py @@ -1,4 +1,5 @@ # Copyright 2018 David Juaneda - +# Copyright 2021 Sodexis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models @@ -21,6 +22,7 @@ class MailActivityMixin(models.AbstractModel): :return: action. """ _id = kwargs.get("id") + model = kwargs.get("model") action = self.env["mail.activity"].action_activities_board() views = [] for v in action["views"]: @@ -28,5 +30,5 @@ class MailActivityMixin(models.AbstractModel): v = (v[0], "list") views.append(v) action["views"] = views - action["domain"] = [("res_id", "=", _id)] + action["domain"] = [("res_id", "=", _id), (("res_model", "=", model))] return action diff --git a/mail_activity_board/readme/CONTRIBUTORS.rst b/mail_activity_board/readme/CONTRIBUTORS.rst index 5c49273..5530d75 100644 --- a/mail_activity_board/readme/CONTRIBUTORS.rst +++ b/mail_activity_board/readme/CONTRIBUTORS.rst @@ -2,9 +2,9 @@ * David Juaneda -* `Eficent `_: +* `ForgeFlow `_: - * Miquel Raïch (miquel.raich@eficent.com) + * Miquel Raïch (miquel.raich@forgeflow.com) * `Pesol `_: diff --git a/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js new file mode 100644 index 0000000..940ffd4 --- /dev/null +++ b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js @@ -0,0 +1,57 @@ +/* Copyright 2018 David Juaneda + * Copyright 2021 Sodexis + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +odoo.define( + "mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js", + function (require) { + "use strict"; + + var rpc = require("web.rpc"); + + const components = { + ChatterTopbar: require("mail/static/src/components/chatter_topbar/chatter_topbar.js"), + }; + + const {patch} = require("web.utils"); + + patch( + components.ChatterTopbar, + "mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js", + { + // -------------------------------------------------------------------------- + // Handlers + // -------------------------------------------------------------------------- + + /** + * @private + * @param {MouseEvent} ev + */ + // eslint-disable-next-line no-unused-vars + _onListActivity(ev) { + var self = this; + rpc.query({ + model: this.chatter.thread.model, + method: "redirect_to_activities", + args: [[]], + kwargs: { + id: this.chatter.thread.id, + model: this.chatter.thread.model, + }, + context: {}, + }).then(function (action) { + self.env.bus.trigger("do-action", { + action, + options: { + on_close: () => { + this.chatter.thread.refreshActivities(); + this.chatter.thread.refresh(); + }, + }, + }); + }); + }, + } + ); + } +); diff --git a/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml new file mode 100644 index 0000000..6adeb11 --- /dev/null +++ b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/mail_activity_board/static/src/js/override_chatter.js b/mail_activity_board/static/src/js/override_chatter.js deleted file mode 100644 index 19d497c..0000000 --- a/mail_activity_board/static/src/js/override_chatter.js +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2018 David Juaneda - * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -odoo.define("mail.Chatter.activity", function (require) { - "use strict"; - - var chatter = require("mail.Chatter"); - - chatter.include({ - events: _.extend({}, chatter.prototype.events, { - "click .o_chatter_button_list_activity": "_onListActivity", - }), - - /** - * Performs the action to redirect to the activities of the object. - * - * @private - */ - _onListActivity: function () { - this._rpc({ - model: this.record.model, - method: "redirect_to_activities", - args: [[]], - kwargs: { - id: this.record.res_id, - model: this.record.model, - }, - context: this.record.getContext(), - }).then($.proxy(this, "do_action")); - }, - }); -}); diff --git a/mail_activity_board/static/src/xml/inherit_chatter.xml b/mail_activity_board/static/src/xml/inherit_chatter.xml deleted file mode 100644 index 2a0ab8e..0000000 --- a/mail_activity_board/static/src/xml/inherit_chatter.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/mail_activity_board/views/mail_activity_view.xml b/mail_activity_board/views/mail_activity_view.xml index 9576a0e..179a629 100644 --- a/mail_activity_board/views/mail_activity_view.xml +++ b/mail_activity_board/views/mail_activity_view.xml @@ -144,6 +144,7 @@ /> - + diff --git a/mail_activity_board/views/templates.xml b/mail_activity_board/views/templates.xml index c042c21..2a6ff5b 100644 --- a/mail_activity_board/views/templates.xml +++ b/mail_activity_board/views/templates.xml @@ -8,7 +8,7 @@