← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-addons/6.1-lp1342369-fetchmail_file_storage_duplicate_attachment_ids into lp:ocb-addons/6.1

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/ocb-addons/6.1-lp1342369-fetchmail_file_storage_duplicate_attachment_ids into lp:ocb-addons/6.1.

Requested reviews:
  OpenERP Community Backports (ocb)

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-addons/6.1-lp1342369-fetchmail_file_storage_duplicate_attachment_ids/+merge/226928

See bug description
-- 
https://code.launchpad.net/~therp-nl/ocb-addons/6.1-lp1342369-fetchmail_file_storage_duplicate_attachment_ids/+merge/226928
Your team OpenERP Community Backports is requested to review the proposed merge of lp:~therp-nl/ocb-addons/6.1-lp1342369-fetchmail_file_storage_duplicate_attachment_ids into lp:ocb-addons/6.1.
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2013-09-10 15:12:35 +0000
+++ mail/mail_thread.py	2014-07-15 21:15:50 +0000
@@ -221,7 +221,12 @@
                     'res_model': thread._name,
                     'res_id': thread.id,
                 }
-                to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context))
+
+                attachment_id = ir_attachment.create(cr, uid, data_attach, context=context)
+                # Document module can return the same ID multiple times if the
+                # same document is attached twice due to deduplication
+                if attachment_id not in to_attach:
+                    to_attach.append(attachment_id)
 
             partner_id = hasattr(thread, 'partner_id') and (thread.partner_id and thread.partner_id.id or False) or False
             if not partner_id and thread._name == 'res.partner':