summaryrefslogtreecommitdiff
path: root/addons/fetchmail/fetchmail.py
diff options
context:
space:
mode:
authorStephane Wirtel <stw@openerp.com>2011-09-22 15:08:27 +0200
committerStephane Wirtel <stw@openerp.com>2011-09-22 15:08:27 +0200
commit7afbca3af907b6ab6ee11f2b6826593b6aead068 (patch)
treeac5123a10a49640f3e185667909fd8e58d52ced0 /addons/fetchmail/fetchmail.py
parente3e5fe5cbe8b611fa3263bd1b022d7e30cdcc87a (diff)
[IMP] fetchmail: Introduce the fetchmail_model keyword in the context to specify the default value for the object field of the fetchmail.server object
bzr revid: stw@openerp.com-20110922130827-ny2i17lng1x1ua59
Diffstat (limited to 'addons/fetchmail/fetchmail.py')
-rw-r--r--addons/fetchmail/fetchmail.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index b7460965c3b..f45b5e955a0 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -78,6 +78,22 @@ class fetchmail_server(osv.osv):
'attach': True,
}
+ def default_get(self, cr, uid, fields, context=None):
+ if context is None:
+ context = {}
+
+ result = super(fetchmail_server, self).default_get(cr, uid, fields, context=context)
+
+ model = context.pop('fetchmail_model', False) or False
+
+ if isinstance(model, basestring):
+ model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model)], context=context)
+ result.update(
+ object_id = model_id[0],
+ )
+
+ return result
+
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
port = 0
if server_type == 'pop':