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-20120622093123-wpk8ht454w7p2c1w