From c92749d93cb15a613ff50d220d766012ef0dbea6 Mon Sep 17 00:00:00 2001 From: Ioan Galan Date: Fri, 7 May 2021 16:46:45 +0200 Subject: [PATCH] [MIG] mail_optional_follower_notification: Migration to 14.0 --- mail_optional_follower_notification/__manifest__.py | 2 +- mail_optional_follower_notification/models/mail_thread.py | 6 ++++++ .../tests/test_mail_optional_follower_notifications.py | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mail_optional_follower_notification/__manifest__.py b/mail_optional_follower_notification/__manifest__.py index 9ac1bf921..dfa5c76a3 100644 --- a/mail_optional_follower_notification/__manifest__.py +++ b/mail_optional_follower_notification/__manifest__.py @@ -6,7 +6,7 @@ "author": "ACSONE SA/NV," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/social", "category": "Social Network", - "version": "13.0.1.1.0", + "version": "14.0.1.0.0", "license": "AGPL-3", "depends": ["mail"], "data": ["wizard/mail_compose_message_view.xml"], diff --git a/mail_optional_follower_notification/models/mail_thread.py b/mail_optional_follower_notification/models/mail_thread.py index d2b70f1d4..a9da2b549 100644 --- a/mail_optional_follower_notification/models/mail_thread.py +++ b/mail_optional_follower_notification/models/mail_thread.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models +from odoo.tools import config class MailThread(models.AbstractModel): @@ -10,7 +11,12 @@ class MailThread(models.AbstractModel): def _notify_compute_recipients(self, message, msg_vals): """Compute recipients to notify based on subtype and followers. This method returns data structured as expected for ``_notify_recipients``.""" + test_condition = config["test_enable"] and not self.env.context.get( + "test_optional_follow_notification" + ) recipient_data = super()._notify_compute_recipients(message, msg_vals) + if test_condition: + return recipient_data if "notify_followers" in self.env.context and not self.env.context.get( "notify_followers", False ): diff --git a/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py b/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py index 439e002cd..af05940a9 100644 --- a/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py +++ b/mail_optional_follower_notification/tests/test_mail_optional_follower_notifications.py @@ -1,10 +1,10 @@ # Copyright 2019 ACSONE SA/NV () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests import common +from odoo.tests.common import SavepointCase -class TestMailOptionalFollowernotifications(common.SavepointCase): +class TestMailOptionalFollowernotifications(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -20,6 +20,7 @@ class TestMailOptionalFollowernotifications(common.SavepointCase): "default_model": "res.partner", "default_res_id": cls.partner_01.id, "default_composition_mode": "comment", + "test_optional_follow_notification": True, } ) cls.mail_compose_context = ctx