From 1b9f3a5b745b305141804d1000227d179aae599f Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Fri, 29 Jun 2012 17:22:33 +0530 Subject: [IMP/FIX] Added Strict value checker for the defaults and fetchmail logger fix bzr revid: jam@tinyerp.com-20120629115233-skml2xtp79xmxvyr --- addons/fetchmail/fetchmail.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/fetchmail/fetchmail.py') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index cddcf642dc4..55923c3043a 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -151,7 +151,7 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS connection = server.connect() server.write({'state':'done'}) except Exception, e: - logger.exception("Failed to connect to %s server %s", server.type, server.name) + _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") % tools.ustr(e)) finally: try: @@ -177,7 +177,7 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS mail_thread = self.pool.get('mail.thread') action_pool = self.pool.get('ir.actions.server') 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) + _logger.info('start checking for new emails on %s server %s', server.type, server.name) context.update({'fetchmail_server_id': server.id, 'server_type': server.type}) count = 0 imap_server = False @@ -198,9 +198,9 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS imap_server.store(num, '+FLAGS', '\\Seen') cr.commit() count += 1 - logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name) + _logger.info("fetched/processed %s email(s) on %s server %s", count, server.type, server.name) except Exception, e: - logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) + _logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) finally: if imap_server: imap_server.close() @@ -222,9 +222,9 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) cr.commit() - logger.info("fetched/processed %s email(s) on %s server %s", numMsgs, server.type, server.name) + _logger.info("fetched/processed %s email(s) on %s server %s", numMsgs, server.type, server.name) except Exception, e: - logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) + _logger.exception("Failed to fetch mail from %s server %s", server.type, server.name) finally: if pop_server: pop_server.quit() -- cgit v1.2.3 From 8541387a0b638ff72955ca4106b3d0061d98bcdc Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Wed, 4 Jul 2012 17:37:18 +0530 Subject: [IMP] fretchmail and mail alias integration bzr revid: jam@tinyerp.com-20120704120718-kkg3qn1gemjkobw6 --- addons/fetchmail/fetchmail.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'addons/fetchmail/fetchmail.py') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 55923c3043a..f0e6a5179b4 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -71,7 +71,7 @@ class fetchmail_server(osv.osv): 'password' : fields.char('Password', size=1024, readonly=True, states={'draft':[('readonly', False)]}), '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', "Create a New Record", required=True, help="Process each incoming mail as part of a conversation " + 'object_id': fields.many2one('ir.model', "Create a New Record", 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)."), @@ -189,10 +189,14 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') - 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 server.object_id: + 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) + else: + res_id = mail_thread.message_catchall(cr, uid, data[0][1]) if res_id and server.action_id: action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) imap_server.store(num, '+FLAGS', '\\Seen') @@ -213,11 +217,14 @@ openerp_mailgate.py -u %(uid)d -p PASSWORD -o %(model)s -d %(dbname)s --host=HOS for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) - 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 server.object_id: + res_id = mail_thread.message_process(cr, uid, server.object_id.model, + msg, + save_original=server.original, + strip_attachments=(not server.attach), + context=context) + else: + res_id = mail_thread.message_catchall(cr, uid, data[0][1]) if res_id and server.action_id: action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) -- cgit v1.2.3