[FIX] snailmail: avoid spam on user mailbox

the fix merged in cb8bd299fc
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.
This commit is contained in:
Rémi Rahir
2018-11-05 09:32:33 +00:00
parent 9988ce3f3b
commit 235811d468
+6 -4
View File
@@ -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()