Skip to content

Commit

Permalink
TA#66891 [16.0][MIG] mail_notification_no_action_button (#146)
Browse files Browse the repository at this point in the history
* [16.0][MIG] mail_notification_no_action_button

---------

Co-authored-by: Majda EL MARIOULI <[email protected]>
  • Loading branch information
abenzbiria and majouda committed Sep 3, 2024
1 parent c82e07a commit c88edda
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mail_notification_no_action_button/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Mail Notification No Action Button
==================================
This module removes action buttons from internal notifications.

Before
------
.. image:: static/description/before.png

After
-----
.. image:: static/description/after.png

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
----------------
* Meet us at https://bit.ly/numigi-com
4 changes: 4 additions & 0 deletions mail_notification_no_action_button/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
17 changes: 17 additions & 0 deletions mail_notification_no_action_button/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Mail Notification No Action Button',
'version': '16.0.1.0.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'license': 'LGPL-3',
'category': 'Discuss',
'summary': 'Remove action buttons from notifications',
'depends': [
'mail',
'crm'
],
'installable': True,
}
4 changes: 4 additions & 0 deletions mail_notification_no_action_button/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import mail_thread
15 changes: 15 additions & 0 deletions mail_notification_no_action_button/models/mail_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models


class MailThread(models.AbstractModel):

_inherit = 'mail.thread'

def _notify_get_recipients_classify(self, *args, **kwargs):
res = super()._notify_get_recipients_classify(*args, **kwargs)
for data in res:
data['actions'] = []
return res
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions mail_notification_no_action_button/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import test_crm_lead
40 changes: 40 additions & 0 deletions mail_notification_no_action_button/tests/test_crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from ddt import ddt, data
from odoo.tests import SavepointCase


@ddt
class TestCRMLead(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = cls.env["res.users"].create(
{
"name": "[email protected]",
"email": "[email protected]",
"login": "[email protected]",
}
)
cls.partner = cls.user.partner_id
cls.lead = cls.env["crm.lead"].create({"name": "M Lead"})
cls.subtype = cls.env.ref("mail.mt_comment")
cls.lead.message_subscribe([cls.partner.id], subtype_ids=[cls.subtype.id])

def send_notification_email(self):
message = self.lead.message_post(
body="Test",
mail_auto_delete=False,
send_after_commit=False,
force_send=True,
subtype_id=self.subtype.id
)
return self.env["mail.mail"].search(
[("mail_message_id", "=", message.id)], limit=1
)

@data("Won", "Lost", "Sales Team Settings")
def test_action_buttons_removed(self, button_label):
email = self.send_notification_email()
assert button_label not in email.body_html

0 comments on commit c88edda

Please sign in to comment.