[FIX] mail: update chatter attachments when a log is deleted

Attachments of the chatter didn't update when a log with an attachment was deleted

Steps to reproduce:
1. Install Sales app
2. Open any sale
3. Create a log note with an image attached
4. Delete the log note
5. The image is still in the sale's chatter attachments

Solution:
When deleting an attachment, send the info on the current partner's bus

OPW-2732793

closes odoo/odoo#83199

X-original-commit: f5f09b7c73bc7a5243a3b6edcfa5d047de33d95e
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Merlin (megu)
2022-01-21 16:50:01 +00:00
parent fbf58629e2
commit ad4cd6df80
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -39,9 +39,12 @@ class IrAttachment(models.Model):
def _delete_and_notify(self):
for attachment in self:
if attachment.res_model == 'mail.channel' and attachment.res_id:
self.env['bus.bus']._sendone(self.env['mail.channel'].browse(attachment.res_id), 'ir.attachment/delete', {
'id': attachment.id,
})
target = self.env['mail.channel'].browse(attachment.res_id)
else:
target = self.env.user.partner_id
self.env['bus.bus']._sendone(target, 'ir.attachment/delete', {
'id': attachment.id,
})
self.unlink()
def _attachment_format(self, commands=False):
+1 -1
View File
@@ -809,7 +809,7 @@ class Message(models.Model):
thread._check_can_update_message_content(self)
self.body = body
if not attachment_ids:
self.attachment_ids.unlink()
self.attachment_ids._delete_and_notify()
else:
message_values = {
'model': self.model,