From dbd3c78aebcb009aeea091b78ec3d58f0afacdf0 Mon Sep 17 00:00:00 2001 From: Joan Mateu Jordi Date: Wed, 17 Nov 2021 09:00:11 +0100 Subject: [PATCH] [15.0][MIG] mail_activity_board: Migration to 15.0 --- mail_activity_board/__manifest__.py | 13 +++- mail_activity_board/models/mail_activity.py | 66 ------------------- .../chatter_topbar/chatter_topbar.esm.js | 45 +++++++++++++ .../chatter_topbar/chatter_topbar.js | 57 ---------------- .../chatter_topbar/chatter_topbar.xml | 2 +- .../tests/test_mail_activity_board.py | 33 +++++----- .../views/mail_activity_view.xml | 2 +- mail_activity_board/views/templates.xml | 15 ----- 8 files changed, 75 insertions(+), 158 deletions(-) create mode 100644 mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.js delete mode 100644 mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js delete mode 100644 mail_activity_board/views/templates.xml diff --git a/mail_activity_board/__manifest__.py b/mail_activity_board/__manifest__.py index 06ec8cd..87e1241 100644 --- a/mail_activity_board/__manifest__.py +++ b/mail_activity_board/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Mail Activity Board", "summary": "Add Activity Boards", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "development_status": "Beta", "category": "Social Network", "website": "https://github.com/OCA/social", @@ -12,6 +12,13 @@ "license": "AGPL-3", "installable": True, "depends": ["calendar", "board"], - "data": ["views/templates.xml", "views/mail_activity_view.xml"], - "qweb": ["static/src/components/chatter_topbar/chatter_topbar.xml"], + "data": ["views/mail_activity_view.xml"], + "assets": { + "web.assets_backend": [ + "mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.js", + ], + "web.assets_qweb": [ + "mail_activity_board/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 573ab22..8cfd77a 100644 --- a/mail_activity_board/models/mail_activity.py +++ b/mail_activity_board/models/mail_activity.py @@ -61,69 +61,3 @@ class MailActivity(models.Model): continue allowed_ids |= self._find_allowed_model_wise(doc_model, doc_dict) return allowed_ids - - @api.model - def _search( - self, - args, - offset=0, - limit=None, - order=None, - count=False, - access_rights_uid=None, - ): - # Rules do not apply to administrator - if self.env.is_superuser(): - return super(MailActivity, self)._search( - args, - offset=offset, - limit=limit, - order=order, - count=count, - access_rights_uid=access_rights_uid, - ) - - ids = super(MailActivity, self)._search( - args, - offset=offset, - limit=limit, - order=order, - count=False, - access_rights_uid=access_rights_uid, - ) - if not ids and count: - return 0 - elif not ids: - return ids - - # check read access rights before checking the actual rules - super( - MailActivity, self.with_user(access_rights_uid or self._uid) - ).check_access_rights("read") - - model_ids = {} - - self.flush(["res_id", "res_model_id", "res_model"]) - for sub_ids in self._cr.split_for_in_conditions(ids): - self._cr.execute( - """ - SELECT DISTINCT a.id, im.id, im.model, a.res_id - FROM "%s" a - LEFT JOIN ir_model im ON im.id = a.res_model_id - WHERE a.id = ANY (%%(ids)s)""" - % self._table, - dict(ids=list(sub_ids)), - ) - for a_id, _ir_model_id, model, model_id in self._cr.fetchall(): - model_ids.setdefault(model, {}).setdefault(model_id, set()).add(a_id) - - allowed_ids = self._find_allowed_doc_ids(model_ids) - - final_ids = allowed_ids - - if count: - return len(final_ids) - else: - # re-construct a list based on ids, because set didn't keep order - id_list = [a_id for a_id in ids if a_id in final_ids] - return id_list diff --git a/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.js b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.js new file mode 100644 index 0000000..253eea1 --- /dev/null +++ b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.js @@ -0,0 +1,45 @@ +/** @odoo-module **/ +import {patch} from "web.utils"; +import {ChatterTopbar} from "@mail/components/chatter_topbar/chatter_topbar"; +const components = {ChatterTopbar}; +// Import {rpc} +import rpc from "web.rpc"; + +patch( + components.ChatterTopbar.prototype, + "mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.esm.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.js b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js deleted file mode 100644 index 940ffd4..0000000 --- a/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.js +++ /dev/null @@ -1,57 +0,0 @@ -/* 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 index 6adeb11..2cc61b5 100644 --- a/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml +++ b/mail_activity_board/static/src/components/chatter_topbar/chatter_topbar.xml @@ -6,7 +6,7 @@ position="after" >