summaryrefslogtreecommitdiff
path: root/addons/fetchmail/fetchmail.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/fetchmail/fetchmail.py')
-rw-r--r--addons/fetchmail/fetchmail.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 7592061ec36..772771db915 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -71,9 +71,9 @@ class email_server(osv.osv):
'user_id': lambda self, cr, uid, ctx: uid,
}
- def check_duplicate(self, cr, uid, ids):
+ 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'])[0]
+ 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:
@@ -105,12 +105,14 @@ class email_server(osv.osv):
return {'value':{'port':port}}
- def set_draft(self, cr, uid, ids, context={}):
+ 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={}):
- for server in self.browse(cr, uid, ids, context):
+ 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('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name))
context.update({'server_id': server.id, 'server_type': server.type})
try:
@@ -144,20 +146,22 @@ class email_server(osv.osv):
logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (e))
return True
- def button_fetch_mail(self, cr, uid, ids, context={}):
+ def button_fetch_mail(self, cr, uid, ids, context=None):
self.fetch_mail(cr, uid, ids, context=context)
return True
- def _fetch_mails(self, cr, uid, ids=False, context={}):
+ def _fetch_mails(self, cr, uid, ids=False, context=None):
if not ids:
ids = self.search(cr, uid, [])
return self.fetch_mail(cr, uid, ids, context=context)
- def fetch_mail(self, cr, uid, ids, context={}):
+ def fetch_mail(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
email_tool = self.pool.get('email.server.tools')
action_pool = self.pool.get('ir.actions.server')
context.update({'get_server': True})
- for server in self.browse(cr, uid, ids, context):
+ for server in self.browse(cr, uid, ids, context=context):
count = 0
user = server.user_id.id or uid
try:
@@ -215,7 +219,7 @@ class mailgate_message(osv.osv):
_order = 'id desc'
def create(self, cr, uid, values, context=None):
- if not context:
+ if context is None:
context={}
server_id = context.get('server_id',False)
server_type = context.get('server_type',False)
@@ -227,7 +231,7 @@ class mailgate_message(osv.osv):
return res
def write(self, cr, uid, ids, values, context=None):
- if not context:
+ if context is None:
context={}
server_id = context.get('server_id',False)
server_type = context.get('server_type',False)