Harry (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-addons-issues5-plugins-pso into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons-issues5-plugins-pso/+merge/124121
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons-issues5-plugins-pso/+merge/124121
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-addons-issues5-plugins-pso.
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2012-09-05 16:01:45 +0000
+++ mail/mail_thread.py	2012-09-13 08:15:27 +0000
@@ -378,7 +378,7 @@
             else:
                 thread_id = model_pool.message_new(cr, user_id, msg, custom_values, context=context)
             self.message_post(cr, uid, [thread_id], context=context, **msg)
-        return True
+        return thread_id
 
     def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
         """Called by ``message_process`` when a new message is received

=== modified file 'plugin/plugin_handler.py'
--- plugin/plugin_handler.py	2012-08-22 11:34:39 +0000
+++ plugin/plugin_handler.py	2012-09-13 08:15:27 +0000
@@ -44,14 +44,14 @@
         res_id = 0
         url = ""
         name = ""
-        msg = self.pool.get('mail.thread').parse_message(cr, uid, email)
-        references = [msg.get('message-id')]
-        refs =  msg.get('references',False)
-        if refs:
-            references.extend(refs.split())
-        msg_ids = mail_message_obj.search(cr, uid, [('message_id','in',references)])
-        if msg_ids:
-            msg = mail_message_obj.browse(cr, uid, msg_ids[0])
+        msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
+        msg_id = msg.get('parent_id', False)
+        message_id = msg.get('message_id')
+        if not msg_id:
+            msg_ids = mail_message_obj.search(cr, uid, [('message_id','=', message_id)])
+            msg_id = len(msg_ids) and msg_ids[0] or False
+        if msg_id:
+            msg = mail_message_obj.browse(cr, uid, msg_id)
             res_id = msg.res_id
             model = msg.model
             url = self._make_url(cr, uid, res_id, model)
@@ -80,7 +80,7 @@
             @return : the result of name_search a list of tuple 
             [(id, 'name')]
         """
-        return self.pool.get(model).name_search(cr,uid,name)
+        return self.pool.get(model).name_search(cr, uid, name)
 
     def push_message(self, cr, uid, model, email, res_id=0):
         """
@@ -91,7 +91,7 @@
         """
         mail_message = self.pool.get('mail.message')
         model_obj = self.pool.get(model)
-        msg = self.pool.get('mail.thread').parse_message(cr, uid, email)
+        msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
         message_id = msg.get('message-id')
         mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)])
         
@@ -103,18 +103,20 @@
             if model == 'res.partner':
                 notify = 'User the Partner button to create a new partner'
             else:
-                res_id = model_obj.message_new(cr, uid, msg)
-                notify = "Mail succesfully pushed, a new %s has been created " % model
+                res_id = model_obj.message_process(cr, uid, model, email)
+                notify = "Mail successfully pushed, a new %s has been created " % model
         else:
-            if model == 'res.partner':
-                model_obj = self.pool.get('mail.thread')
-            model_obj.message_post(cr, uid, [res_id], body=msg)
-            notify = "Mail succesfully pushed"
-            
+            model_obj.message_post(cr, uid, [res_id], 
+                            body= msg.get('body'), 
+                            subject= msg.get('subject'), 
+                            type= 'email', 
+                            parent_id= msg.get('parent_id'), 
+                            attachments= msg.get('attachments'))
+            notify = "Mail successfully pushed"
         url = self._make_url(cr, uid, res_id, model)
         return (model, res_id, url, notify)
 
-    def contact_create(self, cr, uid, data, partner_id):
+    def contact_create(self, cr, uid, data, partner_id, context=None):
         """
             @param data : the data use to create the res.partner
                 [('field_name', value)], field name is required
@@ -123,11 +125,12 @@
             @return : the partner_id sended or created, this allow the plugin to open the right partner page
         """
         partner_obj = self.pool.get('res.partner')
-        dictcreate = dict(data) 
-        if partner_id == 0:
-            partner_id =  partner_obj.create(cr, uid, {'name':dictcreate.get('name')})
-        dictcreate['partner_id'] = partner_id
-        self.pool.get('res.partner').create(cr, uid, dictcreate)
+        dictcreate = dict(data)
+        if partner_id:
+            is_company = partner_obj.browse(cr, uid, partner_id, context=context).is_company
+            if is_company:
+                dictcreate['parent_id'] = partner_id
+        partner_id = partner_obj.create(cr, uid, dictcreate)
         url = self._make_url(cr, uid, partner_id, 'res.partner')
         return ('res.partner', partner_id, url)
 
@@ -146,7 +149,7 @@
         mail_message = self.pool.get('mail.message')        
         ir_attachment_obj = self.pool.get('ir.attachment')
         attach_ids = []
-        msg = self.pool.get('mail.thread').parse_message(cr, uid, headers)
+        msg = self.pool.get('mail.thread').message_parse(cr, uid, headers)
         message_id = msg.get('message-id')    
         push_mail = self.push_message(cr, uid, model, headers, res_id)
         res_id = push_mail[1]
@@ -160,6 +163,6 @@
                 attach_ids.append(ir_attachment_obj.create(cr, uid, vals))
         mail_ids = mail_message.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)])
         if mail_ids:
-            ids =  mail_message.write(cr, uid,mail_ids[0],{ 'attachment_ids': [(6, 0, attach_ids)],'body':body,'body_html':body_html})
+            ids =  mail_message.write(cr, uid, mail_ids[0], { 'attachment_ids': [(6, 0, attach_ids)],'body':body,'body_html':body_html})
         url = self._make_url(cr, uid, res_id, model)
         return (model, res_id, url)

=== modified file 'plugin_thunderbird/static/openerp_plugin.xpi'
Binary files plugin_thunderbird/static/openerp_plugin.xpi	2012-01-30 20:54:50 +0000 and plugin_thunderbird/static/openerp_plugin.xpi	2012-09-13 08:15:27 +0000 differ
=== modified file 'plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin.jar'
Binary files plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin.jar	2012-01-31 13:36:57 +0000 and plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin.jar	2012-09-13 08:15:27 +0000 differ
=== modified file 'plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin/content/create.xul'
--- plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin/content/create.xul	2011-12-26 17:12:29 +0000
+++ plugin_thunderbird/static/thunderbird_plugin/chrome/openerp_plugin/content/create.xul	2012-09-13 08:15:27 +0000
@@ -44,6 +44,6 @@
 	</groupbox>
 	<hbox align="right">
   		<button label="cancel" image="&imagecancel.value;" oncommand="close();" />
-  		<button label="create partner" image="&imageok.value;" oncommand="createContact();"/>
+  		<button label="create contact" image="&imageok.value;" oncommand="createContact();"/>
 	</hbox>
 </window>

_______________________________________________
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