[FIX] mail_gate : update record after geeting reply from user/partner
authorHarry (Open ERP) <hmo@tinyerp.com>
Tue, 5 Jan 2010 12:50:51 +0000 (18:20 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Tue, 5 Jan 2010 12:50:51 +0000 (18:20 +0530)
bzr revid: hmo@tinyerp.com-20100105125051-ctzfukx7jd4ws567

addons/crm/crm_mailgate.py
addons/mail_gateway/mail_gateway.py

index 0d6844c..5c8712a 100644 (file)
@@ -52,7 +52,7 @@ class crm_cases(osv.osv):
             data.update(res)
         return self.create(cr, uid, data)       
     
-    def msg_update(self, cr, uid, id, msg, data={}, default_act='pending'): 
+    def msg_update(self, cr, uid, ids, msg, data={}, default_act='pending'):         
         mailgate_obj = self.pool.get('mail.gateway')
         msg_actions, body_data = mailgate_obj.msg_act_get(msg)           
         data.update({
@@ -77,9 +77,9 @@ class crm_cases(osv.osv):
         if 'partner' in msg_actions:
             data['email_from'] = msg_actions['partner'][:128]
 
-        self.write(cr, uid, [id], data)
-        getattr(self,act)(cr, uid, [id])
-        return True
+        res = self.write(cr, uid, ids, data)        
+        getattr(self,act)(cr, uid, ids)
+        return res
 
     def emails_get(self, cr, uid, ids, context={}):                
         res = []
index a2b406e..79af391 100644 (file)
@@ -155,7 +155,7 @@ class mail_gateway(osv.osv):
                         res_id, note = self.parse_mail(cr, uid, mailgateway.id, data[0][1])
                         log = ''
                         if res_id:
-                            log = _('Object Successfully Created : %d of %s'% (res_id, res_model))
+                            log = _('Object Successfully Created/Modified: %d of %s'% (res_id, res_model))
                         if note:
                             log = note
                         log_messages.append(log)
@@ -280,14 +280,14 @@ class mail_gateway(osv.osv):
 
     def msg_user(self, cr, uid, msg, res_id, res_model):
         actions, body_data = self.msg_act_get(msg)        
-
+        data = {}
         if 'user' in actions:
             uids = self.pool.get('res.users').name_search(cr, uid, actions['user'])
             if uids:
                 data['user_id'] = uids[0][0]
 
         res_model = self.pool.get(res_model)        
-        return res_model.msg_update(cr, uid, msg, res_id, data=data, default_act='pending')        
+        return res_model.msg_update(cr, uid, res_id, msg, data=data, default_act='pending')        
 
     def msg_send(self, msg, reply_to, emails, priority=None, res_id=False):        
         if not emails:
@@ -305,7 +305,7 @@ class mail_gateway(osv.osv):
 
     def msg_partner(self, cr, uid, msg, res_id, res_model):
         res_model = self.pool.get(res_model)        
-        return res_model.msg_update(cr, uid, msg, res_id, data=data, default_act='open')      
+        return res_model.msg_update(cr, uid, res_id, msg, data={}, default_act='open')      
 
     
 
@@ -323,7 +323,8 @@ class mail_gateway(osv.osv):
         def msg_test(res_str):
             emails = ('', '', '', '')
             if not res_str:
-                return (False, emails)            
+                return (False, emails)  
+            res_str = int(res_str)          
             if hasattr(self.pool.get(res_model), 'emails_get'):
                 emails = self.pool.get(res_model).emails_get(cr, uid, [res_str])[0]
             return (res_str, emails)