summaryrefslogtreecommitdiff
path: root/addons/fetchmail/fetchmail.py
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2013-04-05 05:00:26 +0200
committerAntony Lesuisse <al@openerp.com>2013-04-05 05:00:26 +0200
commite48383379328b1f5f2fedd361ea464f6e60732a4 (patch)
tree05190a7539ac8932d71d71d1899f969268085e8b /addons/fetchmail/fetchmail.py
parentaa753772ab0be59682fa478dbefb359caf2fabae (diff)
[FIX] fetchmail, on demand cron, context test for date write
bzr revid: al@openerp.com-20130405030026-oltyhb537w3p273g
Diffstat (limited to 'addons/fetchmail/fetchmail.py')
-rw-r--r--addons/fetchmail/fetchmail.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 230d3e52f5f..d408e7da9ac 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -182,6 +182,7 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
"""WARNING: meant for cron usage only - will commit() after each email!"""
if context is None:
context = {}
+ context['fetchmail_cron_running'] = True
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):
@@ -241,14 +242,17 @@ openerp_mailgate: "|/path/to/openerp-mailgate.py --host=localhost -u %(uid)d -p
return True
def cron_update(self, cr, uid, context=None):
- # Enabled/Disable cron based on the number of 'done' server of type pop or imap
- ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
- try:
- cron_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'fetchmail', 'ir_cron_mail_gateway_action')[1]
- self.pool.get('ir.cron').write(cr, 1, [cron_id], {'active': bool(ids)})
- except ValueError:
- # Nevermind if default cron cannot be found
- pass
+ if context is None:
+ context = {}
+ if not context.get('fetchmail_cron_running'):
+ # Enabled/Disable cron based on the number of 'done' server of type pop or imap
+ ids = self.search(cr, uid, [('state','=','done'),('type','in',['pop','imap'])])
+ try:
+ cron_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'fetchmail', 'ir_cron_mail_gateway_action')[1]
+ self.pool.get('ir.cron').write(cr, 1, [cron_id], {'active': bool(ids)})
+ except ValueError:
+ # Nevermind if default cron cannot be found
+ pass
def create(self, cr, uid, values, context=None):
res = super(fetchmail_server, self).create(cr, uid, values, context=context)