[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)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user