Mail Gate Bugfixes

bzr revid: modifs-8d34c67f0aa87dfc9091711d122fe3c327ca2ec8
This commit is contained in:
modifs 2007-01-08 12:53:11 +00:00
parent 5deb416c89
commit 296ea07fb6
2 changed files with 11 additions and 7 deletions

View File

@ -345,7 +345,7 @@ class crm_case(osv.osv):
if action.act_mail_to_email: if action.act_mail_to_email:
emails += (action.act_mail_to_email or '').split(',') emails += (action.act_mail_to_email or '').split(',')
emails = filter(None, emails) emails = filter(None, emails)
if len(emails): if len(emails) and action.act_mail_body:
self.email_send(cr, uid, case, emails, action.act_mail_body) self.email_send(cr, uid, case, emails, action.act_mail_body)
break break
action_ids = newactions action_ids = newactions

View File

@ -28,21 +28,24 @@ priorities = {
} }
class rpc_proxy(object): class rpc_proxy(object):
def __init__(self, uid, passwd, host='localhost', port=8069, path='object'): def __init__(self, uid, passwd, host='localhost', port=8069, path='object', dbname='terp'):
self.rpc = xmlrpclib.ServerProxy('http://%s:%s/%s' % (host, port, path)) self.rpc = xmlrpclib.ServerProxy('http://%s:%s/%s' % (host, port, path))
self.user_id = uid self.user_id = uid
self.passwd = passwd self.passwd = passwd
self.dbname = dbname
def __call__(self, *request): def __call__(self, *request):
return self.rpc.execute(self.user_id, self.passwd, *request) print self.dbname, self.user_id, self.passwd
return self.rpc.execute(self.dbname, self.user_id, self.passwd, *request)
class email_parser(object): class email_parser(object):
def __init__(self, uid, password, section, email, email_default=None): def __init__(self, uid, password, section, email, email_default, dbname):
self.rpc = rpc_proxy(uid, password) self.rpc = rpc_proxy(uid, password, dbname=dbname)
try: try:
self.section_id = int(section) self.section_id = int(section)
except: except:
self.section_id = self.rpc('crm.case.section', 'search', [('code','=',section)])[0] self.section_id = self.rpc('crm.case.section', 'search', [('code','=',section)])[0]
print 'Section ID', self.section_id
self.email = email self.email = email
self.email_default = email_default self.email_default = email_default
self.canal_id = False self.canal_id = False
@ -219,10 +222,11 @@ if __name__ == '__main__':
parser.add_option("-p", "--password", dest="password", help="Password of the user in Tiny ERP", default='admin') parser.add_option("-p", "--password", dest="password", help="Password of the user in Tiny ERP", default='admin')
parser.add_option("-e", "--email", dest="email", help="Email address used in the From field of outgoing messages") parser.add_option("-e", "--email", dest="email", help="Email address used in the From field of outgoing messages")
parser.add_option("-s", "--section", dest="section", help="ID or code of the case section", default="support") parser.add_option("-s", "--section", dest="section", help="ID or code of the case section", default="support")
parser.add_option("-d", "--default", dest="default", help="Default eMail in case of any trouble.", default=None) parser.add_option("-m", "--default", dest="default", help="Default eMail in case of any trouble.", default=None)
parser.add_option("-d", "--dbname", dest="dbname", help="Database name (default: terp)", default='terp')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
parser = email_parser(options.userid, options.password, options.section, options.email, options.default) parser = email_parser(options.userid, options.password, options.section, options.email, options.default, dbname=options.dbname)
msg_txt = email.message_from_file(sys.stdin) msg_txt = email.message_from_file(sys.stdin)
print 'Mail Sent to ', parser.parse(msg_txt) print 'Mail Sent to ', parser.parse(msg_txt)