[FIX]crm : fixed problems regardig email_from/email_to
authorHarry (Open ERP) <hmo@tinyerp.com>
Tue, 30 Mar 2010 13:34:13 +0000 (19:04 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Tue, 30 Mar 2010 13:34:13 +0000 (19:04 +0530)
bzr revid: hmo@tinyerp.com-20100330133413-35za8j33reo3eoyg

addons/crm/crm.py
addons/crm/scripts/openerp_mailgate/openerp_mailgate.py
addons/crm/wizard/crm_send_email.py

index 45d0434..f19cd4b 100644 (file)
@@ -316,14 +316,19 @@ class crm_case(osv.osv):
                     self.write(cr, uid, [case.id], {'stage_id': s[section][st]})
         return True    
     
-    def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, context={}):
+    def history(self, cr, uid, ids, keyword, history=False, email=False, details=None, email_from=False, context={}):
         cases = self.browse(cr, uid, ids, context=context)
-        return self.__history(cr, uid, cases, keyword=keyword,\
-                               history=history, email=email, details=details,\
+        return self._history(cr, uid, cases, keyword=keyword,\
+                               history=history, email=email, details=details, email_from=email_from, \
                                context=context)
 
     def __history(self, cr, uid, cases, keyword, history=False, email=False, details=None, email_from=False, context={}):
-        model_obj = self.pool.get('ir.model')          
+        model_obj = self.pool.get('ir.model')  
+        if email and type(email) == type([]):
+            email = ','.join(email) 
+        if email_from and type(email_from) == type([]):
+            email_from = ','.join(email_from) 
+       
         for case in cases:
             model_ids = model_obj.search(cr, uid, [('model','=',case._name)])            
             data = {
index 3a7bf18..5a7b888 100755 (executable)
@@ -175,7 +175,7 @@ class email_parser(object):
 
         try:
             id = self.rpc(self.model, 'create', data)
-            self.rpc(self.model, 'history', [id], 'Receive', True, msg['From'], message['body'])
+            self.rpc(self.model, 'history', [id], 'Receive', True, False, message['body'], msg['From'])
             #self.rpc(self.model, 'case_open', [id])
         except Exception, e:
             if getattr(e, 'faultCode', '') and 'AccessError' in e.faultCode:
@@ -290,7 +290,7 @@ class email_parser(object):
 
         self.rpc(self.model, act, [id])
         self.rpc(self.model, 'write', [id], data)
-        self.rpc(self.model, 'history', [id], 'Receive', True, details=body['body'], email_from=msg['From'])
+        self.rpc(self.model, 'history', [id], 'Receive', True, False, body['body'], msg['From'])
         return id
 
     def msg_send(self, msg, emails, priority=None):
@@ -322,7 +322,7 @@ class email_parser(object):
         #    'description':body, 
         #}
         #self.rpc(self.model, 'write', [id], data)
-        self.rpc(self.model, 'history', [id], 'Receive', True, details=message['body'], email_from=msg['From'])
+        self.rpc(self.model, 'history', [id], 'Receive', True, False, message['body'], msg['From'])
         return id
 
     def msg_test(self, msg, case_str):
index ce16739..f76e212 100644 (file)
@@ -181,10 +181,11 @@ class crm_send_new_email(osv.osv_memory):
             model = hist.log_id.model_id.model
             model_pool = self.pool.get(model)
             case = model_pool.browse(cr, uid, hist.log_id.res_id)
-            if 'email_to' in fields and hist.email_to:
-                res.update({'email_to': hist.email_to})
+            if 'email_to' in fields:
+                res.update({'email_to': hist.email_from or (case.user_id and case.user_id.address_id and \
+                            case.user_id.address_id.email) or tools.config.get('email_from',False)})
             if 'email_from' in fields:
-                res.update({'email_from': (case.user_id and case.user_id.address_id and \
+                res.update({'email_from': hist.email_to or (case.user_id and case.user_id.address_id and \
                             case.user_id.address_id.email) or tools.config.get('email_from',False)})
             if 'text' in fields:
                 header = '-------- Original Message --------'