Browse Source

[FIX] module is not an App

[FIX] check last_internal_date before connect server
[FIX] display  count an field message retrieved
pull/932/head
archetipo 10 years ago
committed by Jordi Ballester
parent
commit
a6805990c6
  1. 3
      fetchmail_bydate/__openerp__.py
  2. 22
      fetchmail_bydate/model/fetchmail.py

3
fetchmail_bydate/__openerp__.py

@ -30,7 +30,7 @@
This module allows to fetch email by last message internal date and unseen messages. This module allows to fetch email by last message internal date and unseen messages.
""", """,
'author': "Innoviu srl, Agile Business Group, Odoo Community Association (OCA)", 'author': "Innoviu srl, Agile Business Group, Odoo Community Association (OCA)",
'website': 'http://www.innoviu.it, http://www.agilebg.com',
'website': 'http://www.innoviu.it http://www.agilebg.com',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': ['fetchmail', 'mail'], 'depends': ['fetchmail', 'mail'],
"data": [ "data": [
@ -39,6 +39,5 @@
'demo': [], 'demo': [],
'test': [], 'test': [],
'installable': True, 'installable': True,
'application': True,
'auto_install': False, 'auto_install': False,
} }

22
fetchmail_bydate/model/fetchmail.py

@ -124,15 +124,14 @@ class FetchmailServer(orm.Model):
count, failed = 0, 0 count, failed = 0, 0
last_date = False last_date = False
imap_server = False imap_server = False
if server.type == 'imap':
if server.type == 'imap' and server.last_internal_date:
try: try:
imap_server = server.connect() imap_server = server.connect()
imap_server.select() imap_server.select()
if server.last_internal_date:
count, failed, last_date = self._fetch_from_data_imap(
cr, uid, server, imap_server, mail_thread,
action_pool, count, failed, context=context
)
count, failed, last_date = self._fetch_from_data_imap(
cr, uid, server, imap_server, mail_thread,
action_pool, count, failed, context=context
)
except Exception: except Exception:
_logger.exception( _logger.exception(
"General failure when trying to fetch mail \ "General failure when trying to fetch mail \
@ -144,8 +143,13 @@ class FetchmailServer(orm.Model):
if imap_server: if imap_server:
imap_server.close() imap_server.close()
imap_server.logout() imap_server.logout()
if last_date:
vals = {'last_internal_date': last_date}
server.write(vals)
if last_date:
_logger.info(
"Fetched %d email(s) on %s server %s; \
%d succeeded, %d failed.", count,
server.type, server.name,
(count - failed), failed)
vals = {'last_internal_date': last_date}
server.write(vals)
return super(FetchmailServer, self).fetch_mail( return super(FetchmailServer, self).fetch_mail(
cr, uid, ids, context=context) cr, uid, ids, context=context)
Loading…
Cancel
Save