summaryrefslogtreecommitdiff
path: root/addons/mail/tests
diff options
context:
space:
mode:
authorAchraf (abz) <abz@odoo.com>2020-10-23 06:47:54 +0000
committerThibault Delavallée <tde@odoo.com>2021-01-06 17:03:53 +0000
commit79f27f640ccdd14f285a9dd9fc0ae770c992376f (patch)
treeea7e5b3c37a800fc5f7053f4244b197c4cd74c35 /addons/mail/tests
parent5504ad189f66c63b930ae5a6f5838b8478ba28ec (diff)
[FIX] mail: send notification mail with right access link when using mail.thread
PURPOSE Notification may be sent using a generic mail.thread record, notably when sending user notifications. In that case links to view document are incorrect. HOW TO REPRODUCE Issue - Install "Approvals" - Submit new approval with you as "Request Owner" - Click on "View Approval Request" in your mailbox The link redirects to a 505 error Cause The model is not the correct one and the res_id is undefined Solution Specify the model and the res_id to _notify_get_action_link when creating the link with kwargs SPECIFICATIONS Propagate message value through various notification sub methods. That way we can rely on them if model seems void. Also limit values given as URL parameters to some white listed values. LINKS opw-2358846 Task ID-2379766 Followup of odoo/odoo#60998 Followup of odoo/odoo#61545 Closes odoo/odoo#63292 Closes odoo/enterprise#15585 closes odoo/odoo#64170 X-original-commit: 2b6d2b71f6c60bcf64db440473c88d1dc335acbf Related: odoo/enterprise#15588 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com> Co-authored-by: Achraf Ben Azzouz <abz@odoo.com> Co-authored-by: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/mail/tests')
-rw-r--r--addons/mail/tests/common.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py
index 84b17c9c080..dbd664c9be1 100644
--- a/addons/mail/tests/common.py
+++ b/addons/mail/tests/common.py
@@ -422,6 +422,25 @@ class MailCase(MockEmail):
cls.email_template = cls.env['mail.template'].create(create_values)
return cls.email_template
+
+ def _generate_notify_recipients(self, partners):
+ """ Tool method to generate recipients data according to structure used
+ in notification methods. Purpose is to allow testing of internals of
+ some notification methods, notably testing links or group-based notification
+ details.
+
+ See notably ``MailThread._notify_compute_recipients()``.
+ """
+ return [
+ {'id': partner.id,
+ 'active': True,
+ 'share': partner.partner_share,
+ 'groups': partner.user_ids.groups_id.ids,
+ 'notif': partner.user_ids.notification_type or 'email',
+ 'type': 'user' if partner.user_ids and not partner.partner_share else partner.user_ids and 'portal' or 'customer',
+ } for partner in partners
+ ]
+
# ------------------------------------------------------------
# MAIL ASSERTS WRAPPERS
# ------------------------------------------------------------