From 235811d468c0a9d4a579e21dc6eb5a2d8fe177da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Wed, 31 Oct 2018 12:54:42 +0000 Subject: [PATCH] [FIX] snailmail: avoid spam on user mailbox the fix merged in cb8bd299fcd8ff48969f4c64279e1cfb49560fdb was only tackling half the problem. When you assign a user to an activity, the said user will be notified by email. This also occur if you change the assignee to the next activity even if you change it to the same user. This commit ensures that we only write on the user_id field when we create the next activity and not during the update. --- addons/snailmail/models/snailmail_letter.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/snailmail/models/snailmail_letter.py b/addons/snailmail/models/snailmail_letter.py index b21d6aacb60..2b57ff70a5a 100644 --- a/addons/snailmail/models/snailmail_letter.py +++ b/addons/snailmail/models/snailmail_letter.py @@ -258,20 +258,22 @@ class SnailmailLetter(models.Model): activity = MailActivity.search(domain, limit=1) activity_data = { - 'res_id': letter.res_id, - 'res_model_id': self.env['ir.model']._get(letter.model).id, 'activity_type_id': self.env.ref('mail.mail_activity_data_warning').id, 'summary': '[SNAILMAIL] ' + _('Post letter: an error occured.'), 'note': note, - 'user_id': letter.user_id.id, 'date_deadline': fields.Date.today() } if activity: activity.update(activity_data) else: + activity_data.update({ + 'user_id': letter.user_id.id, + 'res_id': letter.res_id, + 'res_model_id': self.env['ir.model']._get(letter.model).id, + }) MailActivity.create(activity_data) - letter.write({'info_msg': note}) + letter.write({'info_msg': note, 'state': 'error'}) self.env.cr.commit()