Merge lp:~therp-nl/ocb-addons/6.1-lp1342360-fetchmail_file_storage_duplicate_attachment_ids into lp:ocb-addons/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Needs review
Proposed branch: lp:~therp-nl/ocb-addons/6.1-lp1342360-fetchmail_file_storage_duplicate_attachment_ids
Merge into: lp:ocb-addons/6.1
Diff against target: 17 lines (+6/-1)
1 file modified
mail/mail_thread.py (+6/-1)
To merge this branch: bzr merge lp:~therp-nl/ocb-addons/6.1-lp1342360-fetchmail_file_storage_duplicate_attachment_ids
Reviewer Review Type Date Requested Status
OpenERP Community Backports Pending
Review via email: mp+226933@code.launchpad.net

Description of the change

See bug description. The duplication is no longer performed in OpenERP 7.0, so it only affects 6.1

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

What is the deduplication based on? If it's the file's name, we'd rather have to turn that off. For a mail, it's perfectly valid to have two times 'attachment.pdf' containing different documents.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Ouch, you are right. While the file size is passed to _check_duplication, it is ignored further down and any file on the same resource with the same name is considered a dupe. The same thing happens on write(), in which case the data is being overwritten. This could be a 'feature' that other parts of the code depend on, and changing this behaviour could lead to an unexpected explosion of documents with the same name. I need to think about a possible solution to this.

Unmerged revisions

6848. By Stefan Rijnhart (Opener)

[FIX] Don't write duplicate attachment ids on incoming mail

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mail/mail_thread.py'
2--- mail/mail_thread.py 2013-09-10 15:12:35 +0000
3+++ mail/mail_thread.py 2014-07-15 21:27:25 +0000
4@@ -221,7 +221,12 @@
5 'res_model': thread._name,
6 'res_id': thread.id,
7 }
8- to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context))
9+
10+ attachment_id = ir_attachment.create(cr, uid, data_attach, context=context)
11+ # Document module can return the same ID multiple times if the
12+ # same document is attached twice due to deduplication
13+ if attachment_id not in to_attach:
14+ to_attach.append(attachment_id)
15
16 partner_id = hasattr(thread, 'partner_id') and (thread.partner_id and thread.partner_id.id or False) or False
17 if not partner_id and thread._name == 'res.partner':

Subscribers

People subscribed via source and target branches