[MERGE] mail: avoid obscure failure when processing batches of emails with attachments
This issue was caused by the way browse_records are cached, in combination with the deletion of messages just after sending them. When processing a second message, the attachment.datas function fields gets computed for all messages that are being browsed, including the first message that was already deleted, causing an exception. The value of the function field had already been computed for the first message, but had been discarded by the message.refresh() call. Hopefully this kind of issue will disappear once we implement the new ORM API. bzr revid: odo@openerp.com-20120622152536-42b2s28lvdv3odyr
This commit is contained in:
@@ -518,12 +518,13 @@ class mail_message(osv.osv):
|
||||
context=context)
|
||||
if res:
|
||||
message.write({'state':'sent', 'message_id': res})
|
||||
message_sent = True
|
||||
else:
|
||||
message.write({'state':'exception'})
|
||||
message_sent = False
|
||||
|
||||
# if auto_delete=True then delete that sent messages as well as attachments
|
||||
message.refresh()
|
||||
if message.state == 'sent' and message.auto_delete:
|
||||
if message_sent and message.auto_delete:
|
||||
self.pool.get('ir.attachment').unlink(cr, uid,
|
||||
[x.id for x in message.attachment_ids \
|
||||
if x.res_model == self._name and \
|
||||
|
||||
Reference in New Issue
Block a user