Turkesh Patel (openERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-mail-alias-jam-mail-script-tpa into 
lp:~openerp-dev/openobject-addons/trunk-mail-alias-jam.

Requested reviews:
  Jigar Amin  (OpenERP) (jam-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail-alias-jam-mail-script-tpa/+merge/112697

[IMP] mail: improved openerp_mailgate.py script which will use message_catchall 
method.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-mail-alias-jam-mail-script-tpa/+merge/112697
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-mail-alias-jam.
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2012-06-27 04:57:35 +0000
+++ mail/mail_thread.py	2012-06-29 05:07:19 +0000
@@ -529,8 +529,9 @@
             #_logger.warning("This mailbox does not exist so mail gate will reject this mail.")
             from_email = user_pool.browse(cr, uid, uid, context).user_email
             sub = "Mail Rejection" + msg.get('subject')
-            message = "Respective mailbox does not exist so your mail have been rejected" + msg.get('body')
-            mail_compose_pool.send_mail(cr, uid, {'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message}, context)
+            message = "Respective mailbox does not exist so your mail have been rejected"+'\n' + msg.get('body')
+            msg_id = mail_compose_pool.create(cr, uid ,{'email_from': from_email,'email_to': msg.get('from'),'subject': sub, 'body_text': message})
+            mail_compose_pool.send_mail(cr, uid, [msg_id], context)
 
         return True
 

=== modified file 'mail/static/scripts/openerp_mailgate.py'
--- mail/static/scripts/openerp_mailgate.py	2011-11-09 18:12:56 +0000
+++ mail/static/scripts/openerp_mailgate.py	2012-06-29 05:07:19 +0000
@@ -94,32 +94,21 @@
         return self.rpc.execute(self.dbname, self.user_id, self.passwd, *request, **kwargs)
 
 class EmailParser(object):
-    def __init__(self, uid, password, model, email_default, dbname, host, port):
+    def __init__(self, uid, password, dbname, host, port):
         self.rpc = RPCProxy(uid, password, host=host, port=port, dbname=dbname)
-        try:
-            self.model_id = int(model)
-            self.model = str(model)
-        except:
-            self.model_id = self.rpc('ir.model', 'search', [('model', '=', model)])[0]
-            self.model = str(model)
-        self.email_default = email_default
-
-
-    def parse(self, message, custom_values=None, save_original=None):
+
+
+    def parse(self, message):
         # pass message as bytes because we don't know its encoding until we parse its headers
         # and hence can't convert it to utf-8 for transport
         res_id = self.rpc('mail.thread',
-                          'message_process',
-                          self.model,
-                          xmlrpclib.Binary(message),
-                          custom_values or {},
-                          save_original or False)
+                          'message_catchall',
+                          xmlrpclib.Binary(message))
 
 def configure_parser():
     parser = optparse.OptionParser(usage='usage: %prog [options]', version='%prog v1.1')
     group = optparse.OptionGroup(parser, "Note",
-        "This program parse a mail from standard input and communicate "
-        "with the OpenERP server for case management in the CRM module.")
+        "This program parse a mail from standard input and communicate ")
     parser.add_option_group(group)
     parser.add_option("-u", "--user", dest="userid",
                       help="ID of the user in OpenERP",
@@ -127,9 +116,6 @@
     parser.add_option("-p", "--password", dest="password",
                       help="Password of the user in OpenERP",
                       default=config.OPENERP_DEFAULT_PASSWORD)
-    parser.add_option("-o", "--model", dest="model",
-                      help="Name or ID of crm model",
-                      default="crm.lead")
     parser.add_option("-m", "--default", dest="default",
                       help="Default eMail in case of any trouble.",
                       default=None)
@@ -142,13 +128,6 @@
     parser.add_option("--port", dest="port",
                       help="Port of the OpenERP Server",
                       default=config.OPENERP_PORT)
-    parser.add_option("--custom-values", dest="custom_values",
-                      help="Add Custom Values to the object",
-                      default=None)
-    parser.add_option("-s", dest="save_original",
-                      action="store_true",
-                      help="Attach a copy of original email to the message entry",
-                      default=False)
 
     return parser
 
@@ -162,24 +141,12 @@
 
     email_parser = EmailParser(options.userid,
                                options.password,
-                               options.model,
-                               options.default,
                                dbname=options.dbname,
                                host=options.host,
                                port=options.port)
-
-
     msg_txt = sys.stdin.read()
-
-    custom_values = {}
-    try:
-        custom_values = dict(eval(options.custom_values or {} ))
-    except:
-        import traceback
-        traceback.print_exc()
-
-    try:
-        email_parser.parse(msg_txt, custom_values, options.save_original or False)
+    try:
+        email_parser.parse(msg_txt)
     except Exception:
         msg = '\n'.join([
             'parameters',

_______________________________________________
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