From e8271ffcc7e0d1aad11e20540a5f35b88fd4ac35 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 7 Jul 2017 18:25:59 +0200 Subject: [PATCH] [FIX] mail: avoid attaching auto-notifications to foreign parents `parent_id` fields are common in many models, and thus default values for those fields are sometimes passed in the context. Because mail.message also has `parent_id` field, it would automatically use the default when an automatic message was being posted. While of course, the parent_id value comes from a different model. This "adoption" by a random "parent message" is unexpected, not desired, and it can even cause a very surprising AccessError if the parent message is not readable by the user. Forcing the `parent_id` value during the creation of an automatic message avoids this confusion. One way to trigger the bug was to use the "subtask" stat button to create a child subtask for a project task (it relies on the parent task ID passed in the context) --- addons/mail/models/mail_thread.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 517dfa8fd31..be8df2937df 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2067,6 +2067,7 @@ class MailThread(models.AbstractModel): partner_ids=[(4, pid) for pid in partner_ids], auto_delete=True, auto_delete_message=True, + parent_id=False, # override accidental context defaults subtype_id=self.env.ref('mail.mt_note').id) @api.multi