Comment 1 for bug 1255611

Revision history for this message
Martin (debacle) wrote :

There is also a code problem in addons/mail/mail_mail.py which is related to the bug:

The variable res is assigned to inside a loop. The value is checked after the loop, so only the last value is taken into account, previous values are silently overwritten:

283 email_list = []
284 if recipient_ids:
285 for partner in self.pool.get('res.partner').browse(...
286 email_list.append(self.send_get_email_dict(...
287 else:
288 email_list.append(self.send_get_email_dict(...
...
291 res = None
292 for email in email_list:
293 msg = ir_mail_server.build_email(
294 email_from = mail.email_from,
295 email_to = email.get('email_to'),
...
307 res = ir_mail_server.send_email(cr, uid, msg,
308 mail_server_id=mail.mail_server_id.id, context=context)
309 if res:
310 mail.write({'state': 'sent', 'message_id': res})
311 mail_sent = True
312 else:
313 mail.write({'state': 'exception'})
314 mail_sent = False

IMHO, the right fix would be to not use a loop in line 292 anyway, but sending one email per message, so res would assigned to only once in the first place.