From 7d9d3c5611a1e926730d054ffb57769bdec071bd Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 4 Feb 2011 12:26:27 +0530 Subject: [IMP] replace mail_gateway to email_gateway module in dependancy of module. bzr revid: ysa@tinyerp.com-20110204065627-sfir225ag1bzwgay --- addons/fetchmail/__openerp__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/__openerp__.py b/addons/fetchmail/__openerp__.py index 6d72f6ea917..eba4bb2ee67 100644 --- a/addons/fetchmail/__openerp__.py +++ b/addons/fetchmail/__openerp__.py @@ -2,7 +2,7 @@ #-*- coding:utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # mga@tinyerp.com # @@ -24,9 +24,9 @@ { "name" : "Fetchmail Server", "version" : "1.0", - "depends" : ["base", 'mail_gateway'], + "depends" : ["base", 'email_gateway'], "author" : "OpenERP SA", - "description": """Fetchmail: + "description": """Fetchmail: * Fetch email from Pop / IMAP server * Support SSL * Integrated with all Modules -- cgit v1.2.3 From b931b05bb902efca78fa0df363dda1ff29d5bf3a Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 7 Feb 2011 11:03:04 +0530 Subject: [IMP] replace mailgate_message to email_message in crm, fetchamil and project_issue module. bzr revid: ysa@tinyerp.com-20110207053304-yak3ruc2os2lah7t --- addons/fetchmail/fetchmail.py | 16 ++++++------- addons/fetchmail/fetchmail_view.xml | 48 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index a1209492490..3fae834b045 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -110,7 +110,7 @@ class email_server(osv.osv): def set_draft(self, cr, uid, ids, context=None): self.write(cr, uid, ids , {'state':'draft'}) return True - + def button_confirm_login(self, cr, uid, ids, context=None): if context is None: context = {} @@ -127,7 +127,7 @@ class email_server(osv.osv): imap_server.login(server.user, server.password) ret_server = imap_server - + elif server.type == 'pop': pop_server = None if server.is_ssl: @@ -140,7 +140,7 @@ class email_server(osv.osv): pop_server.user(server.user) pop_server.pass_(server.password) ret_server = pop_server - + self.write(cr, uid, [server.id], {'state':'done'}) if context.get('get_server',False): return ret_server @@ -207,9 +207,9 @@ class email_server(osv.osv): email_server() -class mailgate_message(osv.osv): +class email_message(osv.osv): - _inherit = "mailgate.message" + _inherit = "email.message" _columns = { 'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True), @@ -229,7 +229,7 @@ class mailgate_message(osv.osv): values['server_id'] = server_id if server_type: values['server_type'] = server_type - res = super(mailgate_message,self).create(cr, uid, values, context=context) + res = super(email_message,self).create(cr, uid, values, context=context) return res def write(self, cr, uid, ids, values, context=None): @@ -241,9 +241,9 @@ class mailgate_message(osv.osv): values['server_id'] = server_id if server_type: values['server_type'] = server_type - res = super(mailgate_message,self).write(cr, uid, ids, values, context=context) + res = super(email_message,self).write(cr, uid, ids, values, context=context) return res -mailgate_message() +email_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 7d55f9f5a7a..d029ab5b97a 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -1,7 +1,7 @@ - + email.server.tree email.server @@ -18,7 +18,7 @@ - + email.server.form email.server @@ -68,7 +68,7 @@ - + email.server.search email.server @@ -91,7 +91,7 @@ - + Email Servers email.server @@ -101,18 +101,18 @@ - - - - mailgate.message.tree - mailgate.message + + + email.message.tree + email.message tree - + @@ -120,12 +120,12 @@ - - - mailgate.message.inherit.search - mailgate.message + + + email.message.inherit.search + email.message search - + @@ -136,24 +136,24 @@ - + Messages - mailgate.message + email.message form tree,form {'search_default_emails': 1} - + - + - - + res_model="email.message" src_model="email.server"/> + -- cgit v1.2.3 From 0c7876ac291b720b787f97834ded983b21c30025 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 7 Feb 2011 11:21:57 +0530 Subject: [IMP] replace mailgate.message to email.message in addons module. bzr revid: ysa@tinyerp.com-20110207055157-yr9co24w84kv0yvy --- addons/fetchmail/fetchmail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 3fae834b045..7ebb9198a92 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -61,7 +61,7 @@ class email_server(osv.osv): 'object_id': fields.many2one('ir.model', "Model", required=True, help="OpenObject Model. Generates a record of this model.\nSelect Object with message_new attrbutes."), 'priority': fields.integer('Server Priority', readonly=True, states={'draft':[('readonly', False)]}, help="Priority between 0 to 10, select define the order of Processing"), 'user_id':fields.many2one('res.users', 'User', required=False), - 'message_ids': fields.one2many('mailgate.message', 'server_id', 'Messages', readonly=True), + 'message_ids': fields.one2many('email.message', 'server_id', 'Messages', readonly=True), } _defaults = { 'state': lambda *a: "draft", -- cgit v1.2.3 From 93f54b8f038f370e8325429f7f0f017ad49475b1 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 7 Feb 2011 12:59:06 +0530 Subject: [IMP] email, email_template and email_gateway related changes done in addons module.. bzr revid: ysa@tinyerp.com-20110207072906-knh218shj8ufyxu7 --- addons/fetchmail/fetchmail_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index d029ab5b97a..b823c586dbf 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -102,7 +102,7 @@ + parent="email.menu_email_message_tools" action="action_view_mail_message_emails" /> Date: Mon, 7 Feb 2011 14:25:38 +0530 Subject: [IMP] improve view in email and fetchmail module. bzr revid: ysa@tinyerp.com-20110207085538-4os2e6toajhjey36 --- addons/fetchmail/fetchmail_view.xml | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index b823c586dbf..35685e46e4c 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -116,7 +116,6 @@ - -- cgit v1.2.3 From 26447d3f5092b22d60e8d519c2e37360ce52775e Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 8 Feb 2011 14:23:11 +0530 Subject: [MOV] change module name email to emails bzr revid: ysa@tinyerp.com-20110208085311-yepv15l0pskvrmc2 --- addons/fetchmail/fetchmail_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 35685e46e4c..591fe944111 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -102,7 +102,7 @@ email.message.tree email.message tree - + @@ -124,7 +124,7 @@ email.message.inherit.search email.message search - + @@ -146,7 +146,7 @@ + parent="emails.menu_email_message_tools" action="action_view_mail_message_emails" /> Date: Wed, 9 Feb 2011 12:53:36 +0530 Subject: [IMP] add access rules in emails and email_gateway module. remove message menu in fetch_mail. bzr revid: ysa@tinyerp.com-20110209072336-qcv2nvl3eavq08ws --- addons/fetchmail/fetchmail_view.xml | 3 --- 1 file changed, 3 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 591fe944111..1563b66bf4f 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -145,9 +145,6 @@ - - Date: Tue, 15 Feb 2011 13:01:50 +0530 Subject: [IMP+FIX] emails: menu name improvement for Incomming server and Outgoing Server and fix regression in markertin compain module bzr revid: hmo@tinyerp.com-20110215073150-q3r9hyk41ryn1jjx --- addons/fetchmail/fetchmail_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 1563b66bf4f..f03d8f91a72 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -93,7 +93,7 @@ - Email Servers + Incomming Servers email.server form tree,form @@ -102,10 +102,10 @@ -- cgit v1.2.3 From 0d5cc2663c9fc664f129ba72fe92d2caa17cfc3f Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 14:33:44 +0530 Subject: [IMP] fetchmail :- imap and pop server fetchmail keep in try and server quit in finally block. bzr revid: ysa@tinyerp.com-20110228090344-uf965sg7hvkrv7o2 --- addons/fetchmail/fetchmail.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 892313c0102..bcd4448beca 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -167,8 +167,8 @@ class email_server(osv.osv): for server in self.browse(cr, uid, ids, context=context): count = 0 user = server.user_id.id or uid - try: - if server.type == 'imap': + if server.type == 'imap': + try: imap_server = self.button_confirm_login(cr, uid, [server.id], context=context) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') @@ -182,12 +182,17 @@ class email_server(osv.osv): count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + + finally: imap_server.close() imap_server.logout() - elif server.type == 'pop': + elif server.type == 'pop': + try: pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) - pop_server.list() (numMsgs, totalSize) = pop_server.stat() + pop_server.list() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) @@ -196,14 +201,12 @@ class email_server(osv.osv): action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) - - pop_server.quit() - logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) - except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) - + finally: + pop_server.quit() return True email_server() -- cgit v1.2.3 From 8df17faa84cd69bdb65b7824e936ec64fc37f921 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 14:39:19 +0530 Subject: [IMP] emails :- add email_from field in search view and remove email filter. bzr revid: ysa@tinyerp.com-20110228090919-r68zey4af7u8btze --- addons/fetchmail/fetchmail_view.xml | 4 ---- 1 file changed, 4 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index f03d8f91a72..fec467083a7 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -126,10 +126,6 @@ search - - - - -- cgit v1.2.3 From 062c57e4b0f6532ae1e80f2fbf2d0b27e2f020f2 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Mar 2011 16:13:05 +0530 Subject: [REMOVE] fetchmail :- remove server_type in email.message object. bzr revid: ysa@tinyerp.com-20110301104305-qtfqy8fkr8xifime --- addons/fetchmail/fetchmail.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index e69bbdf87a2..296d592396a 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -117,7 +117,7 @@ class email_server(osv.osv): context = {} for server in self.browse(cr, uid, ids, context=context): logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) - context.update({'server_id': server.id, 'server_type': server.type}) + context.update({'server_id': server.id}) try: if server.type == 'imap': imap_server = None @@ -215,22 +215,14 @@ class email_message(osv.osv): _columns = { 'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True), - 'server_type':fields.selection([ - ('pop', 'POP Server'), - ('imap', 'IMAP Server'), - ], 'Server Type', select=True, readonly=True), } - _order = 'id desc' def create(self, cr, uid, values, context=None): if context is None: context={} server_id = context.get('server_id',False) - server_type = context.get('server_type',False) if server_id: values['server_id'] = server_id - if server_type: - values['server_type'] = server_type res = super(email_message,self).create(cr, uid, values, context=context) return res @@ -238,11 +230,8 @@ class email_message(osv.osv): if context is None: context={} server_id = context.get('server_id',False) - server_type = context.get('server_type',False) if server_id: values['server_id'] = server_id - if server_type: - values['server_type'] = server_type res = super(email_message,self).write(cr, uid, ids, values, context=context) return res -- cgit v1.2.3 From 4ff5f75912df44cba5465a1db3f41ae88a9faccc Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 3 Mar 2011 16:07:40 +0530 Subject: [FIX] fetchmail: fix bzr revid: hmo@tinyerp.com-20110303103740-rza71diijr9hlysf --- addons/fetchmail/fetchmail.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 296d592396a..4b2b44a5414 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -185,8 +185,9 @@ class email_server(osv.osv): except Exception, e: logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) finally: - imap_server.close() - imap_server.logout() + if imap_server: + imap_server.close() + imap_server.logout() elif server.type == 'pop': try: pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) @@ -204,7 +205,8 @@ class email_server(osv.osv): except Exception, e: logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) finally: - pop_server.quit() + if pop_server: + pop_server.quit() return True email_server() -- cgit v1.2.3 From e1afe5828aa5bc65a61ee6143a2dabd2fa6c0e33 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 10 Mar 2011 13:09:00 +0530 Subject: [IMP] change module name emails to email and related to changes in addons all module. move email_gateway module file in email module and also related changes in related module.. bzr revid: ysa@tinyerp.com-20110310073900-ivesygpb7cdwpp43 --- addons/fetchmail/__openerp__.py | 2 +- addons/fetchmail/fetchmail_view.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/__openerp__.py b/addons/fetchmail/__openerp__.py index eba4bb2ee67..c474edf6c95 100644 --- a/addons/fetchmail/__openerp__.py +++ b/addons/fetchmail/__openerp__.py @@ -24,7 +24,7 @@ { "name" : "Fetchmail Server", "version" : "1.0", - "depends" : ["base", 'email_gateway'], + "depends" : ["base", 'email'], "author" : "OpenERP SA", "description": """Fetchmail: * Fetch email from Pop / IMAP server diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index fec467083a7..be3b2184a3e 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -102,7 +102,7 @@ email.message.tree email.message tree - + @@ -124,7 +124,7 @@ email.message.inherit.search email.message search - + -- cgit v1.2.3 From 455fb2d6b349df99449e1b8655349be8ce2869db Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Fri, 18 Mar 2011 19:14:19 +0530 Subject: [IMP] email: email cleanup bzr revid: rha@tinyerp.com-20110318134419-78qmipdipsryqgnz --- addons/fetchmail/fetchmail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 4b2b44a5414..7e514141fea 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -161,7 +161,7 @@ class email_server(osv.osv): def fetch_mail(self, cr, uid, ids, context=None): if context is None: context = {} - email_tool = self.pool.get('email.server.tools') + thread_pool = self.pool.get('email.thread') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context=context): @@ -174,7 +174,7 @@ class email_server(osv.osv): result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') - res_id = email_tool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) + res_id = thread_pool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) if res_id and server.action_id: action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) @@ -196,7 +196,7 @@ class email_server(osv.osv): for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) - res_id = email_tool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context) + res_id = thread_pool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context) if res_id and server.action_id: action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) -- cgit v1.2.3 From 47a85e9f8f0fadf16d679a2f1fdbef0ef1c59440 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Mon, 4 Apr 2011 15:15:52 +0530 Subject: [IMP] mail: rename module email to mail because of parsing error bzr revid: rha@tinyerp.com-20110404094552-j2rdq2sbeqrbffgn --- addons/fetchmail/__openerp__.py | 2 +- addons/fetchmail/fetchmail.py | 6 +++--- addons/fetchmail/fetchmail_view.xml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/__openerp__.py b/addons/fetchmail/__openerp__.py index acef441b882..b955ab013fb 100644 --- a/addons/fetchmail/__openerp__.py +++ b/addons/fetchmail/__openerp__.py @@ -24,7 +24,7 @@ { "name" : "Fetchmail Server", "version" : "1.0", - "depends" : ["base", 'email'], + "depends" : ["base", 'mail'], "author" : "OpenERP SA", "category": 'Tools', "description": """ diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 7e514141fea..5749fd423ca 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -146,7 +146,7 @@ class email_server(osv.osv): if context.get('get_server',False): return ret_server except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (e)) + logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (e)) return True def button_fetch_mail(self, cr, uid, ids, context=None): @@ -183,7 +183,7 @@ class email_server(osv.osv): logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e))) finally: if imap_server: imap_server.close() @@ -203,7 +203,7 @@ class email_server(osv.osv): pop_server.dele(num) logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e))) finally: if pop_server: pop_server.quit() diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 2bbe251856a..785cec55c5d 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -102,7 +102,7 @@ email.message.tree email.message tree - + @@ -124,7 +124,7 @@ email.message.inherit.search email.message search - + @@ -141,7 +141,7 @@ - -- cgit v1.2.3 From 8ae0447cc08c7cd198b4b5141e85c04831f91510 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Tue, 5 Apr 2011 17:55:10 +0530 Subject: [IMP] mail: improvements in email.message view and rename the sortcut 'Attachments' as 'Messages' for fetchmail form view and also changed domain for that bzr revid: rha@tinyerp.com-20110405122510-2udrv4a7pfa7446u --- addons/fetchmail/fetchmail_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index 785cec55c5d..883c816bf7f 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -143,7 +143,7 @@ -- cgit v1.2.3 From 131daf04aadf22a35f11e81ceb8725debd475f9f Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Wed, 6 Apr 2011 10:07:52 +0530 Subject: [FIX] mail: In email.therad, fixed message_new and message_update method bzr revid: hmo@tinyerp.com-20110406043752-nqpgav3h6f0rk8v1 --- addons/fetchmail/fetchmail.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 5749fd423ca..3e479b76e3d 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -82,21 +82,9 @@ class email_server(osv.osv): return False return True - def check_model(self, cr, uid, ids, context = None): - if context is None: - context = {} - current_rec = self.read(cr, uid, ids, context) - if current_rec: - current_rec = current_rec[0] - model_name = self.pool.get('ir.model').browse(cr, uid, current_rec.get('object_id')[0]).model - model = self.pool.get(model_name) - if hasattr(model, 'message_new'): - return True - return False - _constraints = [ (check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password']), - (check_model, 'Warning! Record for selected Model can not be created\nPlease choose valid Model', ['object_id']) + ] def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False): -- cgit v1.2.3 From 8f9f45ea948d1ffecb79601e860d522fc6686c2d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 22 Aug 2011 19:16:59 +0200 Subject: [IMP] all: next pass of review/renaming for new mail API bzr revid: odo@openerp.com-20110822171659-zxho36a6n628i10q --- addons/fetchmail/fetchmail.py | 11 +++++------ addons/fetchmail/fetchmail_view.xml | 14 +++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 3fe296c50bf..f201ff7560d 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -149,7 +149,7 @@ class email_server(osv.osv): def fetch_mail(self, cr, uid, ids, context=None): if context is None: context = {} - thread_pool = self.pool.get('email.thread') + thread_pool = self.pool.get('mail.thread') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context=context): @@ -201,9 +201,9 @@ class email_server(osv.osv): email_server() -class email_message(osv.osv): +class mail_message(osv.osv): - _inherit = "email.message" + _inherit = "mail.message" _columns = { 'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True), @@ -215,7 +215,7 @@ class email_message(osv.osv): server_id = context.get('server_id',False) if server_id: values['server_id'] = server_id - res = super(email_message,self).create(cr, uid, values, context=context) + res = super(mail_message,self).create(cr, uid, values, context=context) return res def write(self, cr, uid, ids, values, context=None): @@ -224,9 +224,8 @@ class email_message(osv.osv): server_id = context.get('server_id',False) if server_id: values['server_id'] = server_id - res = super(email_message,self).write(cr, uid, ids, values, context=context) + res = super(mail_message,self).write(cr, uid, ids, values, context=context) return res -email_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index bdf25b40f74..d3470cec6eb 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -109,8 +109,8 @@ /> - email.message.tree - email.message + mail.message.tree + mail.message tree @@ -121,8 +121,8 @@ - email.message.inherit.search - email.message + mail.message.inherit.search + mail.message search @@ -134,7 +134,7 @@ Messages - email.message + mail.message form tree,form {'search_default_emails': 1} @@ -143,8 +143,8 @@ + id="act_server_history" name="Messages" domain="[('email_from', '!=', False), ('server_id', '=', active_id)]" + res_model="mail.message" src_model="email.server"/> -- cgit v1.2.3 From b0bed63351956455a23cdc960292e104af53f67a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 23 Aug 2011 19:58:09 +0200 Subject: [IMP] mail.thread: renaming methods to avoid collisions with objects that use the mixin bzr revid: odo@openerp.com-20110823175809-hw81fkptg90702vh --- addons/fetchmail/fetchmail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index f201ff7560d..584de80b198 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -162,7 +162,7 @@ class email_server(osv.osv): result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') - res_id = thread_pool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) + res_id = thread_pool.message_process(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) if res_id and server.action_id: action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) @@ -184,7 +184,7 @@ class email_server(osv.osv): for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) - res_id = thread_pool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context) + res_id = thread_pool.message_process(cr, user, server.object_id.model, msg, attach=server.attach, context=context) if res_id and server.action_id: action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) -- cgit v1.2.3 From d81f1cd942b0678fe9d4b63c3e0755654755e79c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 8 Sep 2011 03:07:00 +0200 Subject: [IMP] fetchmail: review+cleanup bzr revid: odo@openerp.com-20110908010700-n7fk9hzwb60v80cq --- addons/fetchmail/__openerp__.py | 37 ++++-- addons/fetchmail/fetchmail.py | 175 +++++++++++++------------- addons/fetchmail/fetchmail_installer_view.xml | 2 +- addons/fetchmail/fetchmail_view.xml | 84 ++++++------- 4 files changed, 156 insertions(+), 142 deletions(-) (limited to 'addons/fetchmail') diff --git a/addons/fetchmail/__openerp__.py b/addons/fetchmail/__openerp__.py index 4fce528d070..986c3bc12a1 100644 --- a/addons/fetchmail/__openerp__.py +++ b/addons/fetchmail/__openerp__.py @@ -21,19 +21,42 @@ ############################################################################## { - "name" : "Fetchmail Server", + "name" : "Automated Email Retriever", "version" : "1.0", "depends" : ["base", 'mail'], "author" : "OpenERP SA", "category": 'Tools', "description": """ -Fetch email from POP / IMAP servers. -==================================== +Retrieve incoming email on POP / IMAP servers +============================================= - * Supports SSL - * Integrated with all modules - * Automatically receive email - * Email-based record operations (Add, Update) +Enter the parameters of your POP/IMAP account(s), and any incoming +emails on these accounts will be automatically downloaded into your OpenERP +system. All POP3/IMAP-compatible servers are supported, included those +that require an encrypted SSL/TLS connection. + +This can be used to easily create email-based workflows for many +email-enabled OpenERP documents, such as: + + * CRM Leads/Opportunities + * CRM Claims + * Project Issues + * Project Tasks + * Human Resource Recruitments (Applicants) + * etc. + +Just install the relevant application, and you can assign any of +these document types (Leads, Project Issues, etc.) to your incoming +email accounts. New emails will automatically spawn new documents +of the chosen type, so it's a snap to create a mailbox-to-OpenERP +integration. Even better: these documents directly act as mini +conversations synchronized by email. You can reply from within +OpenERP, and the answers will automatically be collected when +they come back, and attached to the same *conversation* document. + +For more specific needs, you may also assign custom-defined actions +(technically: Server Actions) to be triggered for each incoming +mail. """, 'website': 'http://www.openerp.com', 'init_xml': [], diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 584de80b198..46f10f69ff5 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -19,8 +19,8 @@ # ############################################################################## +import logging import time - from imaplib import IMAP4 from imaplib import IMAP4_SSL from poplib import POP3 @@ -30,63 +30,54 @@ import netsvc from osv import osv, fields import tools -logger = netsvc.Logger() +logger = logging.getLogger('fetchmail') class email_server(osv.osv): _name = 'email.server' _description = "POP/IMAP Server" + _order = 'priority' _columns = { 'name':fields.char('Name', size=256, required=True, readonly=False), 'active':fields.boolean('Active', required=False), 'state':fields.selection([ ('draft', 'Not Confirmed'), - ('waiting', 'Waiting for Verification'), ('done', 'Confirmed'), ], 'State', select=True, readonly=True), - 'server' : fields.char('Server', size=256, required=True, readonly=True, states={'draft':[('readonly', False)]}), + 'server' : fields.char('Server Name', size=256, required=True, readonly=True, help="Hostname or IP of the mail server", states={'draft':[('readonly', False)]}), 'port' : fields.integer('Port', required=True, readonly=True, states={'draft':[('readonly', False)]}), 'type':fields.selection([ ('pop', 'POP Server'), ('imap', 'IMAP Server'), - ], 'Server Type', select=True, readonly=False), - 'is_ssl':fields.boolean('SSL ?', required=False), - 'attach':fields.boolean('Add Attachments ?', required=False, help="Fetches mail with attachments if true."), - 'date': fields.date('Date', readonly=True, states={'draft':[('readonly', False)]}), - 'user' : fields.char('User Name', size=256, required=True, readonly=True, states={'draft':[('readonly', False)]}), - 'password' : fields.char('Password', size=1024, invisible=True, required=True, readonly=True, states={'draft':[('readonly', False)]}), + ], 'Server Type', select=True, required=True, readonly=False), + 'is_ssl':fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP3S=995)"), + 'attach':fields.boolean('Keep Attachments', help="Whether attachments should be downloaded. " + "If not enabled, incoming emails will be stripped of any attachments before being processed"), + 'original':fields.boolean('Keep Original', help="Whether a full original copy of each email should be kept for reference" + "and attached to each processed message. This will usually double the size of your message database."), + 'date': fields.datetime('Last Fetch Date', readonly=True), + 'user' : fields.char('Username', size=256, required=True, readonly=True, states={'draft':[('readonly', False)]}), + 'password' : fields.char('Password', size=1024, required=True, readonly=True, states={'draft':[('readonly', False)]}), 'note': fields.text('Description'), - 'action_id':fields.many2one('ir.actions.server', 'Email Server Action', required=False, domain="[('state','=','email')]", help="An Email Server Action. It will be run whenever an e-mail is fetched from server."), - 'object_id': fields.many2one('ir.model', "Object To Create", required=True, help="Whenever an email arrives, it automatically creates the object of this type with all the information attached."), - 'priority': fields.integer('Server Priority', readonly=True, states={'draft':[('readonly', False)]}, help="Priority between 0 to 10, select define the order of Processing"), - 'user_id':fields.many2one('res.users', 'User', required=False, help="This is the user that runs the cron"), + 'action_id':fields.many2one('ir.actions.server', 'Server Action', help="Optional custom server action to trigger for each incoming mail, " + "on the record that was created or updated by this mail"), + 'object_id': fields.many2one('ir.model', "Target document type", required=True, help="Process each incoming mail as part of a conversation " + "corresponding to this document type. This will create " + "new documents for new conversations, or attach follow-up " + "emails to the existing conversations (documents)."), + 'priority': fields.integer('Server Priority', readonly=True, states={'draft':[('readonly', False)]}, help="Defines the order of processing, " + "lower values mean higher priority"), 'message_ids': fields.one2many('mail.message', 'server_id', 'Messages', readonly=True), } _defaults = { - 'state': lambda *a: "draft", - 'active': lambda *a: True, - 'priority': lambda *a: 5, - 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'user_id': lambda self, cr, uid, ctx: uid, + 'state': "draft", + 'active': True, + 'priority': 5, + 'attach': True, } - def check_duplicate(self, cr, uid, ids, context=None): - # RFC *-* Why this limitation? why not in SQL constraint? - vals = self.read(cr, uid, ids, ['user', 'password'], context=context)[0] - cr.execute("select count(id) from email_server where user=%s and password=%s", (vals['user'], vals['password'])) - res = cr.fetchone() - if res: - if res[0] > 1: - return False - return True - - _constraints = [ - (check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password']), - - ] - def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False): port = 0 if server_type == 'pop': @@ -100,113 +91,119 @@ class email_server(osv.osv): self.write(cr, uid, ids , {'state':'draft'}) return True + def connect(self, cr, uid, server_id, context=None): + if isinstance(server_id, (list,tuple)): + server_id = server_id[0] + server = self.browse(cr, uid, server_id, context) + if server.type == 'imap': + if server.is_ssl: + connection = IMAP4_SSL(server.server, int(server.port)) + else: + connection = IMAP4(server.server, int(server.port)) + connection.login(server.user, server.password) + elif server.type == 'pop': + if server.is_ssl: + connection = POP3_SSL(server.server, int(server.port)) + else: + connection = POP3(server.server, int(server.port)) + #TODO: use this to remove only unread messages + #connection.user("recent:"+server.user) + connection.user(server.user) + connection.pass_(server.password) + return connection + def button_confirm_login(self, cr, uid, ids, context=None): if context is None: context = {} for server in self.browse(cr, uid, ids, context=context): - logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) - context.update({'server_id': server.id, 'server_type': server.type}) try: - if server.type == 'imap': - imap_server = None - if server.is_ssl: - imap_server = IMAP4_SSL(server.server, int(server.port)) - else: - imap_server = IMAP4(server.server, int(server.port)) - - imap_server.login(server.user, server.password) - ret_server = imap_server - - elif server.type == 'pop': - pop_server = None - if server.is_ssl: - pop_server = POP3_SSL(server.server, int(server.port)) - else: - pop_server = POP3(server.server, int(server.port)) - - #TODO: use this to remove only unread messages - #pop_server.user("recent:"+server.user) - pop_server.user(server.user) - pop_server.pass_(server.password) - ret_server = pop_server - - self.write(cr, uid, [server.id], {'state':'done'}) - if context.get('get_server',False): - return ret_server + connection = server.connect() + server.write({'state':'done'}) except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (e)) - return True - - def button_fetch_mail(self, cr, uid, ids, context=None): - self.fetch_mail(cr, uid, ids, context=context) + logger.exception("Failed to connect to %s server %s", server.type, server.name) + raise osv.except_osv(_("Connection test failed!"), _("Here is what we got instead:\n %s") % e) + finally: + try: + if connection: + if server.type == 'imap': + connection.close() + elif server.type == 'pop': + connection.quit() + except Exception: + # ignored, just a consequence of the previous exception + pass return True def _fetch_mails(self, cr, uid, ids=False, context=None): if not ids: - ids = self.search(cr, uid, []) + ids = self.search(cr, uid, [('state','=','done')]) return self.fetch_mail(cr, uid, ids, context=context) def fetch_mail(self, cr, uid, ids, context=None): + """WARNING: meant for cron usage only - will commit() after each email!""" if context is None: context = {} - thread_pool = self.pool.get('mail.thread') + mail_thread = self.pool.get('mail.thread') action_pool = self.pool.get('ir.actions.server') - context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context=context): + logger.info('start checking for new emails on %s server %s', server.type, server.name) + context.update({'server_id': server.id, 'server_type': server.type}) count = 0 - user = server.user_id.id or uid if server.type == 'imap': try: - imap_server = self.button_confirm_login(cr, uid, [server.id], context=context) + imap_server = server.connect() imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') - res_id = thread_pool.message_process(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) + res_id = mail_thread.message_process(cr, uid, server.object_id.model, data[0][1], + save_original=server.original, + strip_attachments=(not server.attach), + context=context) if res_id and server.action_id: - action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) - + action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) imap_server.store(num, '+FLAGS', '\\Seen') + cr.commit() count += 1 - logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) - + logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name) except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e))) + logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) finally: if imap_server: imap_server.close() imap_server.logout() elif server.type == 'pop': try: - pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) + pop_server = server.connect() (numMsgs, totalSize) = pop_server.stat() pop_server.list() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) - res_id = thread_pool.message_process(cr, user, server.object_id.model, msg, attach=server.attach, context=context) + res_id = mail_thread.message_process(cr, uid, server.object_id.model, + msg, + save_original=server.original, + strip_attachments=(not server.attach), + context=context) if res_id and server.action_id: - action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) - + action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) - - pop_server.quit() - logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) + cr.commit() + logger.info("fetched/processed %s email(s) on %s server %s", numMsgs, server.type, server.name) except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_ERROR, '%s' % (tools.ustr(e))) + logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) finally: if pop_server: pop_server.quit() + server.write({'date': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)}) return True -email_server() - class mail_message(osv.osv): _inherit = "mail.message" _columns = { - 'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True), + 'server_id': fields.many2one('email.server', "Inbound Mail Server", readonly=True, select=True), } def create(self, cr, uid, values, context=None): diff --git a/addons/fetchmail/fetchmail_installer_view.xml b/addons/fetchmail/fetchmail_installer_view.xml index 34cfc686a8d..791ff2180cd 100644 --- a/addons/fetchmail/fetchmail_installer_view.xml +++ b/addons/fetchmail/fetchmail_installer_view.xml @@ -1,7 +1,7 @@ - Setup Your Mail server + Setup Inbound Mail Server (fetchmail) ir.actions.act_window email.server form diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index d3470cec6eb..5f5c094a454 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -7,12 +7,12 @@ email.server tree - + - + @@ -29,16 +29,14 @@ - - - + - - + + @@ -46,24 +44,28 @@ - - - - - - + - + + + + + + + + + +