dsh (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-mail-attachment-order into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail-attachment-order/+merge/79645

Using Fetchmail functionality, each email we receive on the specified email 
address may automatically create a lead, a contact or any other object in 
OpenERP. It also keeps track of email attachments but, these attachments are 
created in random order. This patch allows to create attachment in sequential 
order(same as   they are attached to an original email).
  
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail-attachment-order/+merge/79645
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-mail-attachment-order.
=== modified file 'mail/mail_message.py'
--- mail/mail_message.py	2011-09-12 12:27:58 +0000
+++ mail/mail_message.py	2011-10-18 04:14:19 +0000
@@ -334,8 +334,8 @@
                       'subtype': msg_mime_subtype,
                       'body_text': plaintext_body
                       'body_html': html_body,
-                      'attachments': { 'file1': 'bytes',
-                                       'file2': 'bytes' }
+                      'attachments': [('file1', 'bytes'),
+                                       ('file2', 'bytes') }
                        # ...
                        'original': source_of_email,
                     }
@@ -416,7 +416,7 @@
                 body = tools.html2plaintext(body)
             msg['body_text'] = tools.ustr(body, encoding)
 
-        attachments = {}
+        attachments = []
         if msg_txt.is_multipart() or 'multipart/alternative' in msg.get('content-type', ''):
             body = ""
             if 'multipart/alternative' in msg.get('content-type', ''):
@@ -432,7 +432,7 @@
                 if part.get_content_maintype()=='text':
                     content = part.get_payload(decode=True)
                     if filename:
-                        attachments[filename] = content
+                        attachments.append((filename, content))
                     content = tools.ustr(content, encoding)
                     if part.get_content_subtype() == 'html':
                         msg['body_html'] = content
@@ -442,7 +442,7 @@
                         body = content
                 elif part.get_content_maintype() in ('application', 'image'):
                     if filename :
-                        attachments[filename] = part.get_payload(decode=True)
+                        attachments.append((filename,part.get_payload(decode=True)))
                     else:
                         res = part.get_payload(decode=True)
                         body += tools.ustr(res, encoding)

=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2011-09-13 13:23:40 +0000
+++ mail/mail_thread.py	2011-10-18 04:14:19 +0000
@@ -201,7 +201,8 @@
 
         for thread in threads:
             to_attach = []
-            for fname, fcontent in attachments.items():
+            for attachment in attachments:
+                fname, fcontent = attachment
                 if isinstance(fcontent, unicode):
                     fcontent = fcontent.encode('utf-8')
                 data_attach = {

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to