summaryrefslogtreecommitdiff
path: root/addons/fetchmail/fetchmail.py
diff options
context:
space:
mode:
authorMantavya Gajjar <mga@tinyerp.com>2010-04-21 01:53:59 +0530
committerMantavya Gajjar <mga@tinyerp.com>2010-04-21 01:53:59 +0530
commitb63dd0fd7aa5d8859a123c459bf30aed5091dab5 (patch)
tree3667d1d97f820b36ca321d51d74240d72b15c56e /addons/fetchmail/fetchmail.py
parent0e53e4b64a15c2baa82eca872f29909586cf7b77 (diff)
[FIX]: fix a problem if no method defined for email event
message_new message_update bzr revid: mga@tinyerp.com-20100420202359-iwsu3wcybupaf2qc
Diffstat (limited to 'addons/fetchmail/fetchmail.py')
-rw-r--r--addons/fetchmail/fetchmail.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 041e469a99e..565c4434607 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -253,7 +253,8 @@ class mail_server(osv.osv):
msg['body'] = body
msg['attachments'] = attachents
-
+
+ res_id = False
if msg.get('references', False):
id = False
ref = msg.get('references')
@@ -274,12 +275,20 @@ class mail_server(osv.osv):
vals = {
}
- model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context)
+ if hasattr(model_pool, 'message_update'):
+ model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context)
+ else:
+ logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_update is not define in model %s' % (model_pool._name))
+ return False
res_id = id
else:
model_pool = self.pool.get(server.object_id.model)
- res_id = model_pool.message_new(cr, uid, msg, context)
-
+ if hasattr(model_pool, 'message_new'):
+ res_id = model_pool.message_new(cr, uid, msg, context)
+ else:
+ logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_new is not define in model %s' % (model_pool._name))
+ return False
+
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -333,10 +342,10 @@ class mail_server(osv.osv):
result, data = imap_server.search(None, '(UNSEEN)')
for num in data[0].split():
result, data = imap_server.fetch(num, '(RFC822)')
- self._process_email(cr, uid, server, data[0][1], context)
- imap_server.store(num, '+FLAGS', '\\Seen')
- count += 1
- logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (count, server.name))
+ if self._process_email(cr, uid, server, data[0][1], context):
+ imap_server.store(num, '+FLAGS', '\\Seen')
+ count += 1
+ logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name))
imap_server.close()
imap_server.logout()